Skip to content

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 — self read as an ISO 8601 date, some(Date), or none where it is not one: "2026-10-24".to_date() is some(2026-10-24).
  • to_datetime — self read as an ISO 8601 date-time with no offset, or none.
  • to_instant — self read as an RFC 3339 instant, with Z or an offset, or none.
  • to_duration — self read as an ISO 8601 duration without years or months, or none.
  • parse_date — self read through a strftime pattern as a Date, or none where it does not match: "24.10.2026".parse_date("%d.%m.%Y").
  • parse_datetime — self read through a strftime pattern as a DateTime, or none.
  • parse_instant — self read through a strftime pattern as an Instant, or none; the pattern writes an offset with %z or a zone with %Z.
  • at — The wall-clock reading of self in zone.
  • in_zone — The instant the wall-clock reading self names in zone.
  • offset — The offset from UTC self has at the instant at: PT2H in Berlin in summer.
  • year — The year of self.
  • month — The month of self, 1..12.
  • day — The day of the month of self, 1..31.
  • weekday — The ISO day of the week of self: Monday is 1, Sunday is 7.
  • day_of_year — The day of the year of self, 1..366.
  • iso_week — The ISO week of self, 1..53, in the year iso_year gives.
  • iso_year — The year the ISO week of self belongs to: 2025 for 2024-12-30, the Monday of the first ISO week of 2025.
  • date — The date of self.
  • hour — The hour of self, 0..23.
  • minute — The minute of self, 0..59.
  • second — The second of self, 0..59.
  • nanosecond — The nanoseconds of self past its second.
  • unix_seconds — The whole seconds from 1970-01-01T00:00:00Z to self, rounded toward negative infinity.
  • unix_millis — The whole milliseconds from 1970-01-01T00:00:00Z to self, rounded toward negative infinity.
  • total_seconds — The length of self in seconds, exactly: PT1.5S is 1.5.
  • total_millis — The length of self in whole milliseconds, rounded toward zero.
  • plus — self moved later by by, earlier where by is negative.
  • minus — self moved earlier by by.
  • since — The duration from earlier to self, negative where earlier is after self.
  • add_days — self moved by n days.
  • add_months — self moved by n months, clamped to the last day of the month it lands in: Date("2026-01-31").add_months(1) is 2026-02-28.
  • add_years — self moved by n years, clamped as add_months is: February 29 moved by a year is February 28.
  • days_since — The days from earlier to self, negative where earlier is after it.
  • negate — self with its sign reversed.
  • times — self multiplied by n.
  • truncate — The start of the unit containing self: the first day of the month for Month, the Monday of its ISO week for Week.
  • dates — Every date from self up to and excluding end, as range gives the Ints; empty where end is not after self.
  • fmt — self written through a strftime pattern, the directives parse_date reads: Date("2026-10-24").fmt("%d %B %Y") is "24 October 2026".
  • now — The evaluation instant: the host's clock, or --now.
  • today — The date now() falls on in zone, or in local_zone().
  • local_zone — The evaluation zone: --zone, else the TZ environment variable, else the host's, else UTC.