Axle v0.14.1
Package

std/time/datetime

std/datetime — calendar-aware time formatting and parsing, in pure Axle.

Operates on i64 millis-since-epoch (compatible with std/time::instantNow
and std/sys::now), always in UTC. The calendar is Howard Hinnant's
proleptic Gregorian civil_from_days / days_from_civil, so a date before
the epoch decomposes as correctly as one after it. That rests on floor
division: Axle's / and % truncate toward zero, which would put
-1 ms on 1970-01-01 instead of 1969-12-31.

Free functions

TypeMethod and description
string
formatIso8601(millis : i64) : string UTC instant millis as ISO-8601, e.g. "2026-05-10T14:23:45.123Z".
string
formatDate(millis : i64) : string UTC date of millis as "YYYY-MM-DD", e.g. "2026-05-10".
string
formatTime(millis : i64) : string UTC time of millis as "HH:MM:SS", e.g. "14:23:45".
string
formatHttpDate(millis : i64) : string UTC instant millis as an RFC 7231 HTTP date, e.g.
"Sun, 10 May 2026 14:23:45 GMT".
i32
yearOf(millis : i64) : i32 UTC calendar year of millis.
i32
monthOf(millis : i64) : i32 UTC month of millis, 1..12 (1 = January).
i32
dayOf(millis : i64) : i32 UTC day of month of millis, 1..31.
i32
hourOf(millis : i64) : i32 UTC hour of millis, 0..23.
i32
minuteOf(millis : i64) : i32 UTC minute of millis, 0..59.
i32
secondOf(millis : i64) : i32 UTC second of millis, 0..59.
i32
millisecondOf(millis : i64) : i32 Sub-second millisecond component of millis, 0..999.
i32
dayOfWeek(millis : i64) : i32 UTC day of week of millis: 0 = Sunday … 6 = Saturday.
i64
buildEpochMillis( year : i32, month : i32, day : i32, hour : i32, minute : i32, second : i32, millis : i32 ) : i64 Composes UTC calendar components into milliseconds since the Unix epoch.
An out-of-range component carries into the next unit (month 13 is January
of the following year).
i64
parseIso8601(s : string) : i64 Parses "YYYY-MM-DDTHH:MM:SS[.fff][Z]" (a space may stand for the T)
into milliseconds since the Unix epoch (UTC). A fraction keeps its first
three digits; anything after the optional Z is refused. A component
outside its range is not rejected — it carries into the next unit, as
buildEpochMillis documents — so "2026-13-01" names January 2027.
string
__dtFormatIso(millis : i64) : string
string
__dtFormatDate(millis : i64) : string
string
__dtFormatTime(millis : i64) : string
string
__dtPad(v : i64, width : i32) : string Decimal v zero-padded to width characters, the sign counted in the width.
string
__dtDayName(weekday : i32) : string
string
__dtMonthName(month : i32) : string
i32
__dtZero() : i32
bool
__dtIsDigit(b : i32) : bool
i64
__dtDigits(s : string, start : i64, count : i64) : i64 The count ASCII digits of s from start as a number, or -1 on any non-digit.
string
__dtParseFailure(s : string) : string
i64
__dtMsPerMinute() : i64
i64
__dtMsPerHour() : i64
i64
__dtMsPerDay() : i64
i64
__dtFloorDiv(a : i64, b : i64) : i64 a / b rounded toward negative infinity, for a positive b.
i64
__dtFloorMod(a : i64, b : i64) : i64 a mod b in 0..b, for a positive b.
i64
__dtDays(millis : i64) : i64 Whole days from the epoch to the UTC day holding millis.
i64
__dtMillisOfDay(millis : i64) : i64
i64
__dtEra(days : i64) : i64
i64
__dtDayOfEra(days : i64) : i64 Day of the 400-year era, 0..146096.
i64
__dtYearOfEra(dayOfEra : i64) : i64 Year of the era, 0..399.
i64
__dtDayOfMarchYear(days : i64) : i64 Day of the March-based year, 0..365.
i64
__dtMarchMonth(dayOfYear : i64) : i64 Month of the March-based year, 0 = March … 11 = February.
i32
__dtMonthOfDays(days : i64) : i32
i32
__dtDayOfDays(days : i64) : i32
i64
__dtYearOfDays(days : i64) : i64
i64
__dtDaysFromCivil(year : i64, month : i64, day : i64) : i64

Method detail

#formatIso8601

formatIso8601(millis : i64) : string

UTC instant millis as ISO-8601, e.g. "2026-05-10T14:23:45.123Z".

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#formatDate

formatDate(millis : i64) : string

UTC date of millis as "YYYY-MM-DD", e.g. "2026-05-10".

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#formatTime

formatTime(millis : i64) : string

UTC time of millis as "HH:MM:SS", e.g. "14:23:45".

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#formatHttpDate

formatHttpDate(millis : i64) : string

UTC instant millis as an RFC 7231 HTTP date, e.g.
"Sun, 10 May 2026 14:23:45 GMT".

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#yearOf

yearOf(millis : i64) : i32

UTC calendar year of millis.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#monthOf

monthOf(millis : i64) : i32

UTC month of millis, 1..12 (1 = January).

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#dayOf

dayOf(millis : i64) : i32

UTC day of month of millis, 1..31.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#hourOf

hourOf(millis : i64) : i32

UTC hour of millis, 0..23.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#minuteOf

minuteOf(millis : i64) : i32

UTC minute of millis, 0..59.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#secondOf

secondOf(millis : i64) : i32

UTC second of millis, 0..59.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#millisecondOf

millisecondOf(millis : i64) : i32

Sub-second millisecond component of millis, 0..999.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#dayOfWeek

dayOfWeek(millis : i64) : i32

UTC day of week of millis: 0 = Sunday … 6 = Saturday.

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

#buildEpochMillis

buildEpochMillis( year : i32, month : i32, day : i32, hour : i32, minute : i32, second : i32, millis : i32 ) : i64

Composes UTC calendar components into milliseconds since the Unix epoch.
An out-of-range component carries into the next unit (month 13 is January
of the following year).

Parameters
year full calendar year, e.g. 2026
month 1..12 (1 = January)
day 1..31
hour 0..23
minute 0..59
second 0..59
millis sub-second component, 0..999

#parseIso8601

parseIso8601(s : string) : i64 ! ParseException

Parses "YYYY-MM-DDTHH:MM:SS[.fff][Z]" (a space may stand for the T)
into milliseconds since the Unix epoch (UTC). A fraction keeps its first
three digits; anything after the optional Z is refused. A component
outside its range is not rejected — it carries into the next unit, as
buildEpochMillis documents — so "2026-13-01" names January 2027.

Parameters
s ISO-8601 timestamp text, e.g. "2026-05-10T14:23:45.123Z"
Throws
ParseException if s is not a valid ISO-8601 timestamp

#__dtFormatIso

__dtFormatIso(millis : i64) : string

#__dtFormatDate

__dtFormatDate(millis : i64) : string

#__dtFormatTime

__dtFormatTime(millis : i64) : string

#__dtPad

__dtPad(v : i64, width : i32) : string

Decimal v zero-padded to width characters, the sign counted in the width.

#__dtDayName

__dtDayName(weekday : i32) : string

#__dtMonthName

__dtMonthName(month : i32) : string

#__dtZero

__dtZero() : i32

#__dtIsDigit

__dtIsDigit(b : i32) : bool

#__dtDigits

__dtDigits(s : string, start : i64, count : i64) : i64

The count ASCII digits of s from start as a number, or -1 on any non-digit.

#__dtParseFailure

__dtParseFailure(s : string) : string

#__dtMsPerMinute

__dtMsPerMinute() : i64

#__dtMsPerHour

__dtMsPerHour() : i64

#__dtMsPerDay

__dtMsPerDay() : i64

#__dtFloorDiv

__dtFloorDiv(a : i64, b : i64) : i64

a / b rounded toward negative infinity, for a positive b.

#__dtFloorMod

__dtFloorMod(a : i64, b : i64) : i64

a mod b in 0..b, for a positive b.

#__dtDays

__dtDays(millis : i64) : i64

Whole days from the epoch to the UTC day holding millis.

#__dtMillisOfDay

__dtMillisOfDay(millis : i64) : i64

#__dtEra

__dtEra(days : i64) : i64

#__dtDayOfEra

__dtDayOfEra(days : i64) : i64

Day of the 400-year era, 0..146096.

#__dtYearOfEra

__dtYearOfEra(dayOfEra : i64) : i64

Year of the era, 0..399.

#__dtDayOfMarchYear

__dtDayOfMarchYear(days : i64) : i64

Day of the March-based year, 0..365.

#__dtMarchMonth

__dtMarchMonth(dayOfYear : i64) : i64

Month of the March-based year, 0 = March … 11 = February.

#__dtMonthOfDays

__dtMonthOfDays(days : i64) : i32

#__dtDayOfDays

__dtDayOfDays(days : i64) : i32

#__dtYearOfDays

__dtYearOfDays(days : i64) : i64

#__dtDaysFromCivil

__dtDaysFromCivil(year : i64, month : i64, day : i64) : i64

C class LocalDateTime

An immutable UTC instant with calendar accessors. The value is its
millis-since-epoch; every plus* returns a fresh LocalDateTime, so a
call chain never alters a receiver someone else still holds.

Constructors

TypeMethod and description
constructor(millis : i64) The instant millis since the Unix epoch (UTC).

Method detail

#constructor

constructor(millis : i64)

The instant millis since the Unix epoch (UTC).

Parameters
millis instant, milliseconds since the Unix epoch (UTC)

Methods

Method detail

#now

now() : LocalDateTime

#fromMillis

fromMillis(millis : i64) : LocalDateTime

#fromComponents

fromComponents( year : i32, month : i32, day : i32, hour : i32, minute : i32, second : i32 ) : LocalDateTime

#getYear

getYear(self) : i32

#getMonth

getMonth(self) : i32

#getDay

getDay(self) : i32

#getHour

getHour(self) : i32

#getMinute

getMinute(self) : i32

#getSecond

getSecond(self) : i32

#toMillis

toMillis(self) : i64

#plusDays

plusDays(self, days : i32) : LocalDateTime

#plusHours

plusHours(self, hours : i32) : LocalDateTime

#plusMinutes

plusMinutes(self, minutes : i32) : LocalDateTime

#plusSeconds

plusSeconds(self, seconds : i32) : LocalDateTime

#formatIso

formatIso(self) : string

#formatDate

formatDate(self) : string