π§² Core Getters β
The Tempo class provides an extensive array of zero-cost getters that allow you to seamlessly read properties from the underlying Temporal instance.
TIP
Zero-Cost Lazy Evaluation
Tempo uses a sophisticated proxy-based lazy-evaluation pattern. Accessing a getter (like t.yy) resolves the property on demand, and then overwrites the getter with a static literal. This means the first access is
β‘ Native Temporal Gateway (.zdt) β
The .zdt getter provides direct, zero-overhead access to the underlying native Temporal.ZonedDateTime instance. All tables below cross-reference Tempo's ergonomic shorthand getters with their underlying native zdt.* properties or namespace sources:
| Getter | Type | Description | Example |
|---|---|---|---|
.zdt | Temporal.ZonedDateTime | Direct zero-overhead access to the underlying native Temporal instance | t.zdt.inLeapYear |
π Date Properties β
| Getter / Temporal | Type | Description | Example |
|---|---|---|---|
.yyzdt.year | number | 4-digit Year | 2026 |
.mmzdt.month | number | Month number (1 = Jan, 12 = Dec) | 10 |
.ddzdt.day | number | Day of the month (1β31) | 24 |
.dimzdt.daysInMonth | number | Total days in the month (28β31) | 31 |
.erazdt.era | string | Canonical calendar era identifier (falls back to 'ce' / 'bce' on calendars where zdt.era is undefined, such as iso8601, chinese, and dangi) | 'ce', 'bce', 'reiwa' |
.eonzdt.eraYear | number | Positive integer year within current .era [1] (derived from .yy when zdt.eraYear is undefined) | 2026, 4 |
.jj | number | Integer Julian Day number for the local ISO date (ignoring time of day) [2] | 2461331 |
- Era Year (
.eon) vs. Calendar Year (.yy): While.yyreturns the signed astronomical year (e.g.2026or-3),.eonreturns the positive integer year within the active.era(e.g.2026in CE,4in 4 BCE, or4in Reiwa 4 when using the Japanese calendar). - Astronomical Julian Day (
.jj) vs. Day of Year (.doy):.jjprovides the integer Julian Day Number for the instance's local ISO date (an integer day count elapsed since noon UT on January 1, 4713 BC, in the proleptic Julian calendar, ignoring time of day, e.g.2461331for 2026-10-17). If you need the calendar day within the current year (1β366), use.doy.
β±οΈ Time Properties β
| Getter / Temporal | Type | Description | Example |
|---|---|---|---|
.hhzdt.hour | number | Hour of the day (0β23) | 15 |
.mizdt.minute | number | Minutes of the hour (0β59) | 30 |
.sszdt.second | number | Seconds of the minute (0β59) | 45 |
.mszdt.millisecond | number | Milliseconds of the second (0β999) | 123 |
.uszdt.microsecond | number | Microseconds of the millisecond (0β999) | 456 |
.nszdt.nanosecond | number | Nanoseconds of the microsecond (0β999) | 789 |
.ff | number | Fractional seconds representation | 0.123456789 |
ποΈ ISO Week & Day Alignments β
| Getter / Temporal | Type | Description | Example |
|---|---|---|---|
.yowzdt.yearOfWeek | number | 4-digit ISO week-numbering year | 2026 |
.woyzdt.weekOfYear | number | ISO week number of the year (1β53) | 43 |
.dowzdt.dayOfWeek | number | ISO weekday number (1 = Mon, 7 = Sun) | 6 |
.doyzdt.dayOfYear | number | Day of the year (1β366) | 297 |
π€ Named String Representations β
| Getter / Path | Type | Description | Example |
|---|---|---|---|
.monEnum.keyOf(Tempo.MONTHS, zdt.month) | string | Full English month name (Gregorian registry label) | 'October' |
.mmmEnum.keyOf(Tempo.MONTH, zdt.month) | string | Short English month name (Gregorian registry label) | 'Oct' |
.wkdEnum.keyOf(Tempo.WEEKDAYS, zdt.dayOfWeek) | string | Full English weekday name | 'Saturday' |
.wwwEnum.keyOf(Tempo.WEEKDAY, zdt.dayOfWeek) | string | Short English weekday name | 'Sat' |
π Regional, Timezone & System Properties β
| Getter / Path | Type | Description | Example |
|---|---|---|---|
.tzzdt.timeZoneId | string | IANA Time Zone ID | 'Australia/Sydney' |
.calzdt.calendarId | string | Calendar identifier [3] | 'iso8601', 'gregory' |
.localeintl.locale?.toString() | string | Resolved canonical BCP 47 language tag | 'en-AU', 'en-US' |
.spheregeo.sphere | Tempo.COMPASS |undefined | Resolved terrestrial hemisphere or compass orientation ('north', 'south', 'equator', 'east', 'west') | 'south' |
.tst.epoch[timeStamp ?? 'ms'] | number | bigint | Unix timestamp using configured epoch unit (defaults to 'ms'; number for ss/ms/us, bigint for ns) [4] | 1792843200000 |
.isozdt.toInstant()β€· .toString() | string | Standard ISO 8601 string (RFC 3339) in UTC | '2026-10-24T04:30:45.123456789Z' |
.isValid | boolean | true if the underlying date-time is valid | true |
- Active Calendar (
.cal) vs. Locale Calendar Preference (.intl.info.calendar):.calreturns the instance's active calendar identifier (zdt.calendarId), which controls arithmetic and date representation. To inspect the cultural default calendar associated with the resolved locale (e.g.'gregory'foren-US, or'buddhist'forth-TH), uset.intl.info.calendar. - Configured Epoch Timestamp (
.ts):.tsresolves its value using the configuredtimeStampunit (defaults to'ms'). Only'ms'maps directly to nativezdt.epochMilliseconds. When configured to'ss','us', or'ns',.tsmaps to their respective epoch values ('ss'seconds,'us'microseconds, or'ns'zdt.epochNanoseconds). For an unconditional nanosecond timestamp regardless of instance configuration, uset.epoch.ns.
βοΈ Comparing & Checking Equality β
For chronological sorting (Tempo.compare()), exact-instant or unit-granular equality (Tempo.equals() / t.equals()), and relational/range predicates (t.is.*), see the dedicated Comparisons & Predicates Guide.
ποΈ Structured Namespaces β
In addition to scalar getters, Tempo provides structured sub-namespaces for domain-specific metadata, high-precision epoch units, internationalization, and geographic context.
| Namespace | Type | Sub-Properties | Example Usage |
|---|---|---|---|
.epoch | Readonly<object> | High-precision Unix epoch counters: β’ .ss (number) β seconds since epochβ’ .ms (number) β milliseconds since epochβ’ .us (number) β microseconds since epochβ’ .ns (bigint) β nanoseconds since epoch | t.epoch.ms β 1792843200000t.epoch.ns β 1792843200000000000n |
.intl | TempoIntlNamespace | Internationalization metadata and locale engine: β’ .info (object) β cultural metadata (firstDay, weekend, calendar, minimalDays)β’ .locale (Intl.Locale) β native locale instance | t.intl.info.firstDay β 1t.intl.locale.baseName β 'en-US' |
.geo | Readonly<GeoConfig> | Geographic coordinates and location data: β’ .sphere ('north' | 'south' | 'equator'; always resolved)β’ .latitude, .longitude (number | undefined)β’ .elevation (number | undefined) | t.geo.sphere β 'south't.geo.latitude β -33.87 |
.term | TempoTermRegistry | Dynamic delegator accessing resolved terminology from loaded TermPlugin modules | t.term.season β 'summer't.term.quarter β 'Q1' |
.fmt | Record<string,string | undefined> | Dynamic delegator evaluating named format presets from Tempo.enums.FORMAT and config.registry.formats | t.fmt.date β '2026-10-24't.fmt.display β 'Sat, 24 Oct 2026' |
.is | TempoPredicates | Lazy-memoized predicate namespace for relational checks (before, after, same, between), calendar/state flags (leapYear, weekend, dst), and custom predicates (see Comparisons & Predicates) | t.is.weekend() β truet.is.between(a, b) β false |
ποΈ Metadata & State Inspection β
Beyond date-time properties, Tempo instances expose read-only inspection getters for debugging, parser AST auditing, and plugin registration introspection:
| Getter | Type | Description | Example Usage |
|---|---|---|---|
.config | Readonly<Config> | Active configuration proxy reflecting resolved global defaults and local instance overrides. | t.config.timeZone |
.parse | Internal.Parse | Shadowed view of internal parse state, including active mode, anchor, and matched AST tokens (.result). | t.parse.anchort.parse.result |
ποΈ Design Philosophy: The 3-Tier Rubric β
Tempo v5 intentionally avoids cluttering the top-level prototype with aliases or wrappers for every single Temporal property. Instead, properties are organized into three clear tiers to maximize Developer Experience (DX) while keeping IDE autocompletion fast and uncluttered:
- Tier 1: Core Daily Primitives (
t.*)
High-frequency getters used across the majority of date applications (.yy,.mm,.dd,.hh,.mi,.ss,.dim,.doy,.dow,.iso,.mon, etc.). - Tier 2: Structured Namespaces (
t.<namespace>.*)
Domain-specific sub-properties grouped into clean namespaces (.epoch,.geo,.intl,.term,.is) to prevent flat autocomplete pollution. - Tier 3: The Native Temporal Gateway (
t.zdt.*)
Standard TC39 Temporal properties (.daysInYear,.inLeapYear,.offsetNanoseconds,.hoursInDay,.monthCode) are accessed directly via.zdtwith zero performance overhead and full TypeScript type fidelity.
NOTE
Why aren't properties like t.diy or t.hoursInDay on root?
Rather than introducing dozens of cryptic 3-letter abbreviations or wrapping every native Temporal property, Tempo leaves standardized properties in t.zdt.* (such as t.zdt.daysInYear or t.zdt.hoursInDay). If your application or domain requires custom root getters, Tempo is built to be easily extended.
TIP
Extending Tempo with Custom Getters & Namespaces
Developers are never limited to Tempo's built-in getters. The Tempo class is intentionally open for extension:
- Custom Instance Getters (
defineProperties/defineProperty): Define custom instance getters and methods directly onTempoor an isolated sandbox (Tempo.extend()). Resolver functions are automatically treated as lazy, per-instance memoized getters:typescriptimport { Tempo, defineProperties } from 'tempo-kit'; Tempo.use(defineProperties({ isMonthEnd: (t) => t.dd === t.dim, daysLeftInMonth: (t) => t.dim - t.dd, }, 'DateExtensions')); - Structured Sub-Namespaces: Mount entire custom namespaces (e.g.
t.audit.*ort.astro.*) with automatic proxy resolution and caching usingdefineNamespace. - Reusable Lifecycle Plugins: Package complex behaviors, prototype methods, and static tools using
definePlugin.
Learn more in the comprehensive Extending Tempo with Plugins Guide.