Module:DatetimeUtil/doc

Lua metamodule containing functions for datetime formatting. All datetimes are assumed to be in UTC.


 * : A Unix timestamp; that is, the number of seconds since the Unix epoch.

Constants

 * MIN_TIME =
 * ISO 8601 representation of the Unix epoch.


 * MAX_TIME =
 * ISO 8601 representation of the furthest time that can fit into a signed 32-bit Unix timestamp. Only datetimes between MIN_TIME and MAX_TIME (inclusive) are considered safe for use.


 * MONTHS_FULL =
 * Full English names of the months as a Lua array.


 * MONTHS_SHORT =
 * Abbreviated English names of the months as a Lua array.

ISO 8601 formatting

 * is_iso8601 (s)
 * Returns whether s is a valid ISO 8601 datetime.


 * to_iso8601 (t)
 * Converts a Unix timestamp into its ISO 8601 representation.


 * from_iso8601 (s)
 * If the given argument is a valid ISO 8601 datetime, returns its corresponding Unix timestamp.


 * parse_iso8601 (s)
 * If the given argument is a valid ISO 8601 datetime, parses it and returns 6 values: year, month, day, hours, minutes, and seconds, in that order.


 * make_iso8601 (y, m, d, hh = 0, mm = 0, ss = 0)
 * Returns the ISO 8601 datetime with the given year, month, day, hours, minutes, and seconds.

Cargo datetime formatting

 * is_cargo (s)
 * Returns whether s is a valid Cargo datetime (same as ISO 8601, except without the  and the  ).


 * to_cargo (t)
 * Converts a Unix timestamp into its Cargo representation.


 * from_cargo (s)
 * If the given argument is a valid Cargo datetime, returns its corresponding Unix timestamp. Otherwise, if it is a valid Cargo date (just the  part), returns a Unix timestamp representing 00:00 UTC on the given date.


 * parse_cargo (s)
 * If the given argument is a valid Cargo datetime, parses it and returns 6 values: year, month, day, hours, minutes, and seconds, in that order. If it is a valid Cargo date instead, the three time values are 0.


 * make_cargo (y, m, d, hh = 0, mm = 0, ss = 0)
 * Returns the Cargo datetime with the given year, month, day, hours, minutes, and seconds. This function always produces a datetime and never a date even if the time values are all omitted.

Wiki formatting

 * ht (t_or_s)
 * Formats a time according to ISO 8601 and attaches a Pacific Time tooltip to it. If the argument is a Lua number, it is treated as a Unix timestamp; otherwise, it must be either an ISO 8601 or Cargo datetime. A warning is generated for any invalid datetime arguments. This implementation properly handles Daylight Saving Time changes.


 * HT {t_or_s}
 * For use from wikitext. Notice the uppercase function name. Implements Template:HT.


 * ht_range (t_or_s1, t_or_s2)
 * Formats a datetime range. Converts both arguments to ISO 8601 tooltips and joins them with a hyphen. Either datetime can be nil in order to support indefinite datetime ranges.