Files
cell/docs/api/modules/time.md
2025-02-10 09:48:59 -06:00

104 lines
2.6 KiB
Markdown

# time
The main time object, handling date/time utilities in earth-seconds.
### now() <sub>function</sub>
Return the current system time in seconds (implemented in C extension).
### computer_dst() <sub>function</sub>
Return true if local system time is currently in DST (implemented in C extension).
### computer_zone() <sub>function</sub>
Return local time zone offset from UTC in hours (implemented in C extension).
### second <sub>number</sub>
Number of seconds in a (real) second (always 1).
### minute <sub>number</sub>
Number of seconds in a minute (60).
### hour <sub>number</sub>
Number of seconds in an hour (3600).
### day <sub>number</sub>
Number of seconds in a day (86400).
### week <sub>number</sub>
Number of seconds in a week (604800).
### weekdays <sub>object</sub>
Names of the days of the week, Sunday through Saturday.
### monthstr <sub>object</sub>
Full names of the months of the year, January through December.
### epoch <sub>number</sub>
Base epoch year, from which day 0 is calculated (default 1970).
### hour2minute() <sub>function</sub>
Return the ratio of hour to minute in seconds, e.g. 3600 / 60 => 60.
### day2hour() <sub>function</sub>
Return the ratio of day to hour in seconds, e.g. 86400 / 3600 => 24.
### minute2second() <sub>function</sub>
Return the ratio of minute to second in seconds, e.g. 60 / 1 => 60.
### week2day() <sub>function</sub>
Return the ratio of week to day in seconds, e.g. 604800 / 86400 => 7.
### strparse <sub>object</sub>
Mapping of format tokens (yyyy, mm, dd, etc.) to time fields (year, month, day...).
### isleap(year) <sub>function</sub>
Return true if a given year is leap, based on whether it has 366 days.
### yearsize(y) <sub>function</sub>
Given a year, return 365 or 366 depending on leap-year rules.
### timecode(t, fps = 24) <sub>function</sub>
Convert seconds into a "S:frames" timecode string, with optional FPS (default 24).
### monthdays <sub>object</sub>
An array of days in each month for a non-leap year.
### zones <sub>object</sub>
Table of recognized time zone abbreviations, with offsets (e.g., "-12" -> "IDLW").
### record(num, zone = this.computer_zone() <sub>function</sub>
Convert a timestamp (in seconds) into a record with fields like day, month, year, etc.
### number(rec) <sub>function</sub>
Convert a record back into a numeric timestamp (seconds).
### fmt <sub>string</sub>
Default format string for time.text(), containing tokens like 'yyyy', 'dd', 'hh', etc.
### text(num, fmt = this.fmt, zone) <sub>function</sub>
Format a numeric or record time into a string using a format pattern, e.g. 'hh:nn:ss'.