A duration value may be defined with a combination of several duration units:
second with s
minute with m
hour with h
day with d
week with w
Duration values are integers, positive, or negative.
effect {var d1 = 4d; // 4 daysvar d2 = 1w; // 1 weekvar d3 = 2d10h; // 2 days and 10 hoursvar d4 = -5d; // minus 5 days}
Durations values may be compared with the 6 comparison operators = < > <= >= <>
.
Two duration values may be added or subtracted. It is also possible to multiply a duration by an integer value.
effect {var d1 = 55w; // 55 weeksvar d2 = 3d; // 3 daysvar d3 = d1 + d2 // equal to '55w3d'var d2 = 10 * d3 // 555 weeks}
Date format is ISO 8601.
constant date0 : date = 2019-01-01constant date1 : date = 2019-01-01T01:02:03constant date2 : date = 2019-01-01T01:02:03Zconstant date3 : date = 2019-01-01T00:00:00+01:00constant date4 : date = 2019-01-01T00:00:00-05:30
The subtraction of two dates returns a duration; since the duration is a positive number, if d1
and d2
are two dates, then d1 - d2 = d2 - d2 >= 0
holds.
effect {var d1 := 2020-06-28;var d2 := 2020-05-28;if (d1 - d2 = 4w) then transfer 1tz to coder;}
It is possible to add or subtract a duration to a date value to get a new date.
effect {var d1 := 2020-06-17;if (d1 + 5d = 2020-06-22) then transfer 1tz to coder;}
now
is the keyword to refer to the date at execution.
variable deadline : date = 2020-09-01action submit() {require {r1 : deadline - 8w <= now <= dealine + 1d}effect {...}}