Files
cell/docs/api/modules/time.md
2025-02-09 00:07:01 -06:00

1.3 KiB

time

The main time object, handling date/time utilities in earth-seconds.

now

Return the current system time in seconds (implemented in C extension).

computer_dst

Return true if local system time is currently in DST (implemented in C extension).

computer_zone

Return local time zone offset from UTC in hours (implemented in C extension).

hour2minute

Return the ratio of hour to minute in seconds, e.g. 3600 / 60 => 60.

day2hour

Return the ratio of day to hour in seconds, e.g. 86400 / 3600 => 24.

minute2second

Return the ratio of minute to second in seconds, e.g. 60 / 1 => 60.

week2day

Return the ratio of week to day in seconds, e.g. 604800 / 86400 => 7.

isleap(year)

Return true if a given year is leap, based on whether it has 366 days.

yearsize(y)

Given a year, return 365 or 366 depending on leap-year rules.

timecode(t, fps = 24)

Convert seconds into a "S:frames" timecode string, with optional FPS (default 24).

record(num, zone = this.computer_zone()

Convert a timestamp (in seconds) into a record with fields like day, month, year, etc.

number(rec)

Convert a record back into a numeric timestamp (seconds).

text(num, fmt = this.fmt, zone)

Format a numeric or record time into a string using a format pattern, e.g. 'hh:nn:ss'.