Skip to content

std:datetime/OffsetDateTime

Canonical occurrence: protos/lib/datetime/OffsetDateTime.protos · Protos revision: e99b712ecf658a527b1fe82c8beba2c1286d8dc9.

Local civil date-times paired with one fixed offset. An offset date-time is a frozen ordinary object with a dateTime slot holding a std:datetime/LocalDateTime and an offset slot holding a std:datetime/Offset, both stored exactly as given. It carries no time zone, zone rules, time-zone database version, daylight-saving disambiguation, or clock state.

An offset date-time identifies the std:datetime/Instant reached by subtracting its offset from its local date-time read on the proleptic Gregorian timeline of uniform 86400-second days. The conversions are pure Integer arithmetic and consult no host time-zone, clock, or text service.

Every offset date-time’s immediate delegation parent is this module, the canonical offset date-time factory and prototype. recognizes accepts exactly the offset date-times of this family: objects whose immediate parent is this module, whose local slots are exactly the offset date-time state and behavior slots, and whose components are a recognized local date-time and offset.

Equality is structural: two offset date-times are == when their local date-times are equal and their offsets are equal. Values that identify the same instant through different local date-times and offsets are therefore not equal; sameInstant compares instants explicitly. hash is coherent with structural equality, so equal values work as the same Map key. === remains ordinary object identity. Offset date-times have no natural total order, and this module deliberately provides no compare.

This page lists the complete mechanically observable top-level slot inventory required by D067. Authored documentation, when present, is canonical D062 prose; mechanical presence alone does not create a stability or compatibility promise.

Answers a fresh frozen offset date-time composing dateTime, a value recognized by std:datetime/LocalDateTime, and offset, a value recognized by std:datetime/Offset. The components are stored as given. Any other argument signals an Error.

Answers the offset date-time with offset that identifies instant: the local date-time offset.seconds seconds after instant, read on the proleptic Gregorian calendar from 1970-01-01T00:00:00, paired with the same offset object. Negative positions are normalized with floor division, so every time field lies in its ordinary range. A local date outside std:datetime/Date’s supported years, or arguments that are not an instant and an offset, signal an Error; nothing is wrapped or saturated.

Answers true exactly when value is an offset date-time of this family: its immediate delegation parent is this module, its local slots are exactly dateTime, offset, equals, ==, and hash, dateTime is recognized by std:datetime/LocalDateTime, and offset is recognized by std:datetime/Offset. Answers false for any other value.

Answers true exactly when offset date-times left and right identify the same instant, that is when toInstant(left) == toInstant(right), and false otherwise. Structural == is unaffected. Non-offset date-time arguments signal an Error.

Answers the std:datetime/Instant identified by value: the exact uniform nanoseconds of value.dateTime from 1970-01-01T00:00:00 on the proleptic Gregorian calendar, minus value.offset.seconds seconds. A non-offset date-time argument signals an Error.

Answers the offset date-time with offset that identifies the same instant as value; exactly fromInstant(toInstant(value), offset). The local date-time is recomputed and the given offset object is kept. A local date outside the supported years, or invalid arguments, signal an Error.

Exact module source · Standard-library API · Standard library overview