Skip to main content

Module time

Module time 

Source
Expand description

Dates in a site’s timezone. Ranges are computed here as epoch milliseconds so the database only ever compares integers.

The TypeScript reads local times through Intl.DateTimeFormat, which knows ICU’s zone names. jiff reads the system’s time zone database, which knows nearly the same ones, and the differences are settled here as the PHP port settles them: a name is matched without regard to case, the few that the database keeps as old fixed rules (CET, EST, MST) go to the zone ICU reads them as, ICU’s own extra names (PST, SystemV/EST5EDT) are added, “Factory”, which ICU refuses, is refused, and an offset such as +05:30 is a zone, as ECMA-402 takes one.

Structs§

Bucket
One chart bucket.
Range
A span of time in a site’s timezone.
RangeInput
What a range is asked for with: a period, or custom dates, and an interval.

Constants§

INTERVALS
The intervals a chart may be bucketed by.
PERIODS
The named periods a range may be.

Functions§

add_days
new Date(Date.UTC(y, m - 1, d + days)).toISOString().slice(0, 10).
add_months
The first of the month months from the date’s.
buckets
Chart buckets covering a range, each starting on a local boundary and ending at the next, so only the first and last can be partial. resolve_range picks an interval that fits; a range given here with more buckets than that, such as a longer comparison, is cut off at a boundary, never merged into its last bucket.
compare_range
The range a period is compared with: the same number of days just before it, the same dates a year earlier, or custom dates. None for “off” or bad custom dates.
is_date
Whether the text is a date from 1900 to 9998 that exists.
is_timezone
Whether Intl takes the name as a time zone.
local_date
The local date of an instant, YYYY-MM-DD.
local_weekday_hour
The local weekday (Monday is 0) and hour of an instant.
resolve_range
A named period or custom dates as a range in the site’s timezone. first_date is the earliest local date with data, used by “all”.
start_of
The instant a local date (and hour) begins in a zone.