std/time¶
module time
Time: zones, the units a value truncates to, and the operations over the
time scalars of core: conversion from text, parts, arithmetic,
truncation, rendering, and the evaluation clock. Not in the prelude: a
program writes import time for time.now(), or from time import *
for now().
Zone— A time zone: an IANA name the time-zone database holds,"Europe/Berlin","UTC", or a fixed offset"+02:00".TimeUnit— The units a time value truncates to.Nanosecond— The units a time value truncates to.Microsecond— The units a time value truncates to.Millisecond— The units a time value truncates to.Second— The units a time value truncates to.Minute— The units a time value truncates to.Hour— The units a time value truncates to.Day— The units a time value truncates to.Week— The units a time value truncates to.Month— The units a time value truncates to.Quarter— The units a time value truncates to.Year— The units a time value truncates to.to_date—selfread as an ISO 8601 date,some(Date), ornonewhere it is not one:"2026-10-24".to_date()issome(2026-10-24).to_datetime—selfread as an ISO 8601 date-time with no offset, ornone.to_instant—selfread as an RFC 3339 instant, withZor an offset, ornone.to_duration—selfread as an ISO 8601 duration without years or months, ornone.parse_date—selfread through a strftimepatternas aDate, ornonewhere it does not match:"24.10.2026".parse_date("%d.%m.%Y").parse_datetime—selfread through a strftimepatternas aDateTime, ornone.parse_instant—selfread through a strftimepatternas anInstant, ornone; the pattern writes an offset with%zor a zone with%Z.at— The wall-clock reading ofselfinzone.in_zone— The instant the wall-clock readingselfnames inzone.offset— The offset from UTCselfhas at the instantat:PT2Hin Berlin in summer.year— The year ofself.month— The month ofself,1..12.day— The day of the month ofself,1..31.weekday— The ISO day of the week ofself: Monday is 1, Sunday is 7.day_of_year— The day of the year ofself,1..366.iso_week— The ISO week ofself,1..53, in the yeariso_yeargives.iso_year— The year the ISO week ofselfbelongs to:2025for2024-12-30, the Monday of the first ISO week of 2025.date— The date ofself.hour— The hour ofself,0..23.minute— The minute ofself,0..59.second— The second ofself,0..59.nanosecond— The nanoseconds ofselfpast its second.unix_seconds— The whole seconds from1970-01-01T00:00:00Ztoself, rounded toward negative infinity.unix_millis— The whole milliseconds from1970-01-01T00:00:00Ztoself, rounded toward negative infinity.total_seconds— The length ofselfin seconds, exactly:PT1.5Sis1.5.total_millis— The length ofselfin whole milliseconds, rounded toward zero.plus—selfmoved later byby, earlier wherebyis negative.minus—selfmoved earlier byby.since— The duration fromearliertoself, negative whereearlieris afterself.add_days—selfmoved byndays.add_months—selfmoved bynmonths, clamped to the last day of the month it lands in:Date("2026-01-31").add_months(1)is2026-02-28.add_years—selfmoved bynyears, clamped asadd_monthsis: February 29 moved by a year is February 28.days_since— The days fromearliertoself, negative whereearlieris after it.negate—selfwith its sign reversed.times—selfmultiplied byn.truncate— The start of theunitcontainingself: the first day of the month forMonth, the Monday of its ISO week forWeek.dates— Every date fromselfup to and excludingend, asrangegives theInts; empty whereendis not afterself.fmt—selfwritten through a strftimepattern, the directivesparse_datereads:Date("2026-10-24").fmt("%d %B %Y")is"24 October 2026".now— The evaluation instant: the host's clock, or--now.today— The datenow()falls on inzone, or inlocal_zone().local_zone— The evaluation zone:--zone, else theTZenvironment variable, else the host's, elseUTC.