time.l0

time.l0

Module: std.time

Source: compiler/shared/l0/stdlib/std/time.l0 Language: Dea/L0

Imports / Includes

  • std.integer
  • sys.rt

Symbols

Function is_valid_nsec

1
func is_valid_nsec(nsec: int) -> bool

Checks if the nanosecond component is within valid range [0, 1e9).

Parameters:

  • nsec: The nanosecond value.

Returns: True if valid, false otherwise.

Function is_leap_year

1
func is_leap_year(year: int) -> bool

Determines if a given year is a leap year.

Parameters:

  • year: The year to check.

Returns: True if leap year, false otherwise.

Function days_in_month

1
func days_in_month(year: int, month: int) -> int

Returns the number of days in a given month of a given year.

Parameters:

  • year: The year.
  • month: The month (1-12).

Returns: The number of days in the month.

Function day_of_year

1
func day_of_year(year: int, month: int, day: int) -> int

Calculates the day of the year for a given date.

Parameters:

  • year: The year.
  • month: The month.
  • day: The day of the month.

Returns: The day of the year (1-366).

Function civil_from_unix_days

1
func civil_from_unix_days(days: int) -> CivilDate

Calculates civil date components from Unix days.

Parameters:

  • days: The number of days since the Unix epoch.

Returns: The broken-down CivilDate.

Function datetime_from_unix_sec

1
func datetime_from_unix_sec(unix_sec: int, nsec: int, utc_offset_sec: int, is_dst: bool) -> DateTime?

Creates a DateTime object from Unix seconds and other components.

Parameters:

  • unix_sec: Seconds since Unix epoch.
  • nsec: Nanoseconds component.
  • utc_offset_sec: Offset from UTC in seconds.
  • is_dst: True if daylight saving time is in effect.

Returns: The broken-down DateTime, or null if invalid.

Function wall_now

1
func wall_now() -> WallTime?

Returns the current wall clock time.

Returns: The current WallTime, or null on error.

Function monotonic_supported

1
func monotonic_supported() -> bool

Checks if the monotonic clock is supported by the runtime.

Returns: True if supported, false otherwise.

Function monotonic_now

1
func monotonic_now() -> MonotonicTime?

Returns the current monotonic time.

Returns: The current MonotonicTime, or null if not supported or error.

Function monotonic_diff

1
func monotonic_diff(start: MonotonicTime, end: MonotonicTime) -> Duration?

Calculates the duration between two monotonic time points.

Parameters:

  • start: The starting time.
  • end: The ending time.

Returns: The Duration difference, or null if end < start or overflow.

Function wall_to_utc_datetime

1
func wall_to_utc_datetime(t: WallTime) -> DateTime?

Converts wall clock time to UTC DateTime .

Parameters:

  • t: The wall clock time.

Returns: The UTC DateTime, or null on error.

Function wall_to_local_datetime

1
func wall_to_local_datetime(t: WallTime) -> DateTime?

Converts wall clock time to local DateTime .

Parameters:

  • t: The wall clock time.

Returns: The local DateTime, or null on error.

Function utc_now_datetime

1
func utc_now_datetime() -> DateTime?

Returns the current date and time in UTC.

Returns: The UTC DateTime, or null on error.

Function local_now_datetime

1
func local_now_datetime() -> DateTime?

Returns the current date and time in the local time zone.

Returns: The local DateTime, or null on error.

Struct WallTime

Represents wall clock time in seconds and nanoseconds since the Unix epoch.

WallTime Field sec

1
sec: int

WallTime Field nsec

1
nsec: int

Struct MonotonicTime

Represents monotonic time in seconds and nanoseconds.

MonotonicTime Field sec

1
sec: int

MonotonicTime Field nsec

1
nsec: int

Struct Duration

Represents a duration of time in seconds and nanoseconds.

Duration Field sec

1
sec: int

Duration Field nsec

1
nsec: int

Struct DateTime

Represents a broken-down date and time.

DateTime Field year

1
year: int

DateTime Field month

1
month: int

DateTime Field day

1
day: int

DateTime Field hour

1
hour: int

DateTime Field minute

1
minute: int

DateTime Field second

1
second: int

DateTime Field nanosecond

1
nanosecond: int

DateTime Field weekday

1
weekday: int

DateTime Field yearday

1
yearday: int

DateTime Field utc_offset_sec

1
utc_offset_sec: int

DateTime Field is_dst

1
is_dst: bool

Struct CivilDate

Represents a civil date without time components.

CivilDate Field year

1
year: int

CivilDate Field month

1
month: int

CivilDate Field day

1
day: int

CivilDate Field weekday

1
weekday: int

CivilDate Field yearday

1
yearday: int