compiler/shared/l0/stdlib/std/time.l0
Module std.time
Overview Symbols grouped by source file: compiler/shared/l0/stdlib/std/time.l0
Module: std.time
Source: compiler/shared/l0/stdlib/std/time.l0 Language: Dea/L0
Imports / Includes
std.integersys.rt
Symbols
- is_valid_nsec
- is_leap_year
- days_in_month
- day_of_year
- civil_from_unix_days
- datetime_from_unix_sec
- wall_now
- monotonic_supported
- monotonic_now
- monotonic_diff
- wall_to_utc_datetime
- wall_to_local_datetime
- utc_now_datetime
- local_now_datetime
- WallTime
- MonotonicTime
- Duration
- DateTime
- CivilDate
Function is_valid_nsec
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
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
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
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
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
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
func wall_now() -> WallTime?
Returns the current wall clock time.
Returns: The current WallTime, or null on error.
Function monotonic_supported
func monotonic_supported() -> bool
Checks if the monotonic clock is supported by the runtime.
Returns: True if supported, false otherwise.
Function monotonic_now
func monotonic_now() -> MonotonicTime?
Returns the current monotonic time.
Returns: The current MonotonicTime, or null if not supported or error.
Function monotonic_diff
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
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
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
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
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
sec: int
WallTime Field nsec
nsec: int
Struct MonotonicTime
Represents monotonic time in seconds and nanoseconds.
MonotonicTime Field sec
sec: int
MonotonicTime Field nsec
nsec: int
Struct Duration
Represents a duration of time in seconds and nanoseconds.
Duration Field sec
sec: int
Duration Field nsec
nsec: int
Struct DateTime
Represents a broken-down date and time.
DateTime Field year
year: int
DateTime Field month
month: int
DateTime Field day
day: int
DateTime Field hour
hour: int
DateTime Field minute
minute: int
DateTime Field second
second: int
DateTime Field nanosecond
nanosecond: int
DateTime Field weekday
weekday: int
DateTime Field yearday
yearday: int
DateTime Field utc_offset_sec
utc_offset_sec: int
DateTime Field is_dst
is_dst: bool
Struct CivilDate
Represents a civil date without time components.
CivilDate Field year
year: int
CivilDate Field month
month: int
CivilDate Field day
day: int
CivilDate Field weekday
weekday: int
CivilDate Field yearday
yearday: int