envzn
0.8 · beta · not released

Library / Date and time / Date and time / DateTime

CLASSIMPLEMENTS Comparable<DateTime>, Equatable<DateTime>, Hashable, Cloneable

DateTime

UTC wall-clock instant, millisecond precision.

Fields 7

int32 year
int32 month
int32 day
int32 hour
int32 minute
int32 second
int32 millisecond

Constructors 2

INIT()

Construct from the current wall-clock instant (UTC). Always valid — system time cannot be outside the representable range.

INIT(int64 epochMs)

Construct from a raw Unix epoch ms value. Primarily used by DateTimeFactory.newDateTime after it has validated components and computed epochMs via Calendar.fieldsToEpochMs — that is the supported path for explicit construction, because it surfaces a pipe-XOR FAILURE on out-of-range. Direct use is also fine if you already hold a known-valid epoch (e.g. from another DateTime, from a database column). An epoch outside [year 1, year 9999] splits into proleptic-Gregorian fields outside that range; no FAILURE is raised here, so prefer DateTimeFactory.newDateTime for untrusted input.

Methods 10

METHOD getEpochMs() RETURNS int64
reads

Wall-clock instant as milliseconds since the Unix epoch (UTC).

METHOD isLessThan(REFERENCE DateTime other) RETURNS boolean
reads

Comparable[DateTime] — strict less-than on epochMs (UTC). The ordering operators (<, <=, >, >=) are derived by the compiler from this single method per Comparable's convention.

METHOD equals(REFERENCE DateTime other) RETURNS boolean
reads

Equatable[DateTime] — Comparable's parent. Two DateTimes are equal iff their epochMs match; broken-down field equality is a derived consequence (both split by Calendar from the same ms).

METHOD compareTo(REFERENCE DateTime other) RETURNS TimeComparison
reads

Explicit three-way comparison — for callers that want the named TimeComparison enum (BEFORE / EQUAL / AFTER) rather than composing the Comparable primitives. Both surfaces are intentional per Phase 0 #3 LOCKED.

METHOD __op_plus__(REFERENCE TimeDuration d) RETURNS DateTime
reads

dt + td — shift forward by d. UTC.

METHOD __op_minus__(REFERENCE TimeDuration d) RETURNS DateTime
reads

dt - td — shift back by d. UTC.

METHOD __op_minus__(REFERENCE DateTime other) RETURNS TimeDuration
reads

dt - dt' — the TimeDuration FROM other TO self. Sign follows the convention later - earlier > 0.

METHOD format(REFERENCE String pattern) RETURNS String
reads

Render this DateTime against pattern, substituting each recognised token with its zero-padded field value and copying every other character verbatim.

METHOD hash() RETURNS uint64
reads

FNV-1a 64-bit hash of epochMs, mixed as 8 little-endian bytes. epochMs is the canonical state — two DateTimes with equal epochMs are Equatable-equal and must hash identically.

METHOD clone() RETURNS DateTime
reads

Field copy. Routes through INIT(int64) so the broken-down decomposition runs once on the clone; epochMs is the source of truth, the seven public fields are derived.