Files
mgmt/examples/lang/datetime2.mcl
James Shubin 29eebd0d07 lang: core: Move template to golang namespace
I don't think this template function should be in any way authoritative,
so let's namespace it.
2024-09-13 15:51:24 -04:00

20 lines
583 B
Plaintext

import "datetime"
import "golang"
import "sys"
$secplusone = datetime.now() + $ayear
# note the order of the assignment (year can come later in the code)
$ayear = 60 * 60 * 24 * 365 # is a year in seconds (31536000)
$tmplvalues = struct{year => $secplusone, load => $theload,}
$theload float = sys.load()->x1 # ambiguous so we specify the type!
if 5 > 3 {
file "/tmp/mgmt/datetime" {
state => $const.res.file.state.exists,
content => golang.template("Now + 1 year is: {{ .year }} seconds, aka: {{ datetime_print .year }}\n\nload average: {{ .load }}\n", $tmplvalues),
}
}