Views and Snapshots
A ZView is a projection of an instant through a zone, calendar, and locale. Every ZDate exposes two: utc and local. Views are lazy — fields resolve on first read and are cached — and they are read-only: a view can never change the instant it projects.
Fields
| Getter | Description |
|---|---|
year, month, day, era | Calendar fields in the view's calendar |
hour, minute, second, nanosecond | Clock fields in the view's zone |
epoch | The projected instant's identity |
zone | ZTimeZone for this view |
calendar | ZCalendar for this view |
locale | ZLocale for this view |
Derived Fields
| Getter | Description |
|---|---|
leapYear | Calendar-aware leap year |
daysInMonth / daysInYear | Calendar-aware lengths |
dayOfWeek | ISO day 1–7 |
dayOfYear / weekOfYear / isoQuarter | Position within the year |
firstDayOfWeek | Calendar's first weekday |
monthName / monthAbbr | Localized month names |
weekdayName / weekdayAbbr | Localized weekday names |
dayPeriod | Localized AM/PM |
toString() renders the view as RFC 9557.
Snapshots
snapshot() captures a view's fields as a plain serializable object, and a snapshot is accepted by the ZDate constructor — the memento pattern. This is why the method is on ZView and not named toObject/fromObject on ZDate: a snapshot records a view of the instant (fields as seen through a zone and calendar), and restoring it reconstructs the same instant from that record.
const snap = d.local.snapshot() // plain object; also what toJSON() emits
const restored = new ZDate(snap) // same instantUse snapshots to persist or transmit a date with its view context intact, without inventing a custom serialization.
