Files
mgmt/examples/lang/datetime3.mcl
James Shubin 78936c5ce8 examples: lang: Update examples to fix imports and port from yaml
Some small fixes that are useful for demos!
2019-02-01 03:47:18 -05:00

19 lines
582 B
Plaintext

import "datetime"
import "sys"
import "example"
$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, vumeter => $vumeter,}
$theload = structlookup(sys.load(), "x1")
$vumeter = example.vumeter("====", 10, 0.9)
file "/tmp/mgmt/datetime" {
content => template("Now + 1 year is: {{ .year }} seconds, aka: {{ datetime_print .year }}\n\nload average: {{ .load }}\n\nvu: {{ .vumeter }}\n", $tmplvalues),
}