| epoch --h/int= --m/int= --s/int= --ms/int= --us/int= --ns/int= -> Time | Constructs a time instance from the given parameters. |
|---|---|
| now -> Time | Constructs a time instance for the current moment in time. |
| local --year/int --month/int --day/int --h/int= --m/int= --s/int= --ms/int= --us/int= --ns/int= --dst/bool= -> Time | Constructs a time instance in local time. |
| local year/int month/int day/int h/int= m/int= s/int= --ms/int= --us/int= --ns/int= --dst/bool= -> Time | |
| utc --year/int --month/int --day/int --h/int= --m/int= --s/int= --ms/int= --us/int= --ns/int= -> Time | Constructs a time instance in UTC from the given parameters. |
| utc year/int month/int day/int h/int= m/int= s/int= --ms/int= --us/int= --ns/int= -> Time | |
| deserialize bytes/Data -> Time | Constructs a time instance from the given bytes. |
| from-string str/string -> Time | Parses the given str to construct a UTC time instance. |
| parse str/string [--on-error] -> Time | |
| parse str/string [--if-error] -> Time | Parses the given str to construct a UTC time instance. |
| parse str/string -> Time | |
| monotonic-us --since-wakeup/bool= -> int | Returns a monotonically increasing microsecond value. |
t0 := Time.epoch
t1 := Time.epoch --h=1
t2 := Time.epoch --h=2
t0.compare_to t0 // => 0
t1.compare_to t1 // => 0
t2.compare_to t2 // => 0
t0.compare_to t1 // => -1
t1.compare_to t2 // => -1
t0.compare_to t2 // => -1
t2.compare_to t1 // => 1
t1.compare_to t0 // => 1
t2.compare_to t0 // => 1
main:
// In this example, we assume the time is 2021-04-21 15:30:35 UTC.
time := Time.utc --year=2021 --month=04 --day=21 --h=12 --m=30 --s=35
print time.to-now // >> 3h0m0s
time = Time.utc --year=2021 --month=04 --day=21 --h=18 --m=30 --s=35
print time.to-now // >> --3h0m0s