Skip to main content

time

Package time provides time and duration utilities for durable programs.

load("time", ...)

time​

load("time", "time")

Functions​

sleep(duration: Duration)​

Example:

time.sleep(time.SECOND * 5)

Parameters:

NameTypeRequiredDescription
durationDuration✓

Returns: Duration


now()​

Example:

time.now()

Returns: Time


parse(layout: String, ts: String)​

Example:

time.parse(time.RFC3339, "2024-01-01T00:00:00Z")

Parameters:

NameTypeRequiredDescription
layoutString✓
tsString✓

Returns: Time


duration(duration: String)​

Example:

time.duration("1h30m")

Parameters:

NameTypeRequiredDescription
durationString✓

Returns: Duration


Types​

Duration​

Attributes:

int​

Returns: Int


Month​


Time​

Attributes:

unix​

Returns: Int

utc​

Returns: Time

year​

Returns: Int

month​

Returns: Month

day​

Returns: Int

weekday​

Returns: Weekday

yearday​

Returns: Int

zone​

Returns: Zone


Weekday​


Zone​


Constants​

  • MONDAY - Constant
  • TUESDAY - Constant
  • WEDNESDAY - Constant
  • THURSDAY - Constant
  • FRIDAY - Constant
  • SATURDAY - Constant
  • SUNDAY - Constant
  • JANUARY - Constant
  • FEBRUARY - Constant
  • MARCH - Constant
  • APRIL - Constant
  • MAY - Constant
  • JUNE - Constant
  • JULY - Constant
  • AUGUST - Constant
  • SEPTEMBER - Constant
  • OCTOBER - Constant
  • NOVEMBER - Constant
  • DECEMBER - Constant
  • RFC_822 - Constant
  • RFC_822_Z - Constant
  • RFC_850 - Constant
  • RFC_1123 - Constant
  • RFC_1123_Z - Constant
  • RFC_3339 - Constant
  • RFC_3339_NANO - Constant
  • NANOSECOND - Constant
  • MICROSECOND - Constant
  • MILLISECOND - Constant
  • SECOND - Constant
  • MINUTE - Constant
  • HOUR - Constant