This release introduces the new time extension — a structured, high-precision date/time API with a rich set of functions from working with Unix time to time comparison and arithmetic to truncation and rounding.
Creating time values:
time_now()
time_date(year, month, day[, hour, min, sec[, nsec[, offset_sec]]])
Extracting time fields:
time_get_year(t)
time_get_month(t)
time_get_day(t)
time_get_hour(t)
time_get_minute(t)
time_get_second(t)
time_get_nano(t)
time_get_weekday(t)
time_get_yearday(t)
time_get_isoyear(t)
time_get_isoweek(t)
time_get(t, field)
Unix time:
time_unix(sec[, nsec])
time_milli(msec)
time_micro(usec)
time_nano(nsec)
time_to_unix(t)
time_to_milli(t)
time_to_micro(t)
time_to_nano(t)
Time comparison:
time_after(t, u)
time_before(t, u)
time_compare(t, u)
time_equal(t, u)
Time arithmetic:
time_add(t, d)
time_add_date(t, years[, months[, days]])
time_sub(t, u)
time_since(t)
time_until(t)
Rounding:
time_trunc(t, field)
time_trunc(t, d)
time_round(t, d)
Formatting:
time_fmt_iso(t[, offset_sec])
time_fmt_datetime(t[, offset_sec])
time_fmt_date(t[, offset_sec])
time_fmt_time(t[, offset_sec])
time_parse(s)
Duration constants:
dur_ns()
dur_us()
dur_ms()
dur_s()
dur_m()
dur_h()
See the docs for full details.