Skip to content

time

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

now() function

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

computer_dst() function

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

computer_zone() function

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

second number

Number of seconds in a (real) second (always 1).

minute number

Number of seconds in a minute (60).

hour number

Number of seconds in an hour (3600).

day number

Number of seconds in a day (86400).

week number

Number of seconds in a week (604800).

weekdays object

Names of the days of the week, Sunday through Saturday.

monthstr object

Full names of the months of the year, January through December.

epoch number

Base epoch year, from which day 0 is calculated (default 1970).

hour2minute() function

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

day2hour() function

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

minute2second() function

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

week2day() function

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

strparse object

Mapping of format tokens (yyyy, mm, dd, etc.) to time fields (year, month, day...).

isleap(year) function

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

yearsize(y) function

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

timecode(t, fps = 24) function

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

monthdays object

An array of days in each month for a non-leap year.

zones object

Table of recognized time zone abbreviations, with offsets (e.g., "-12" -> "IDLW").

record(num, zone = this.computer_zone() function

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

number(rec) function

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

fmt string

Default format string for time.text(), containing tokens like 'yyyy', 'dd', 'hh', etc.

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

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