Skip to content

🧲 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 O(1) and every subsequent access is raw property access (O(0) cost).

⚑ 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:

GetterTypeDescriptionExample
.zdtTemporal.ZonedDateTimeDirect zero-overhead access to the underlying native Temporal instancet.zdt.inLeapYear

πŸ“… Date Properties ​

Getter / TemporalTypeDescriptionExample
.yy
zdt.year
number4-digit Year2026
.mm
zdt.month
numberMonth number (1 = Jan, 12 = Dec)10
.dd
zdt.day
numberDay of the month (1–31)24
.dim
zdt.daysInMonth
numberTotal days in the month (28–31)31
.era
zdt.era
stringCanonical calendar era identifier (falls back to 'ce' / 'bce' on calendars where zdt.era is undefined, such as iso8601, chinese, and dangi)'ce', 'bce', 'reiwa'
.eon
zdt.eraYear
numberPositive integer year within current .era [1] (derived from .yy when zdt.eraYear is undefined)2026, 4
.jjnumberInteger Julian Day number for the local ISO date (ignoring time of day) [2]2461331
  1. Era Year (.eon) vs. Calendar Year (.yy): While .yy returns the signed astronomical year (e.g. 2026 or -3), .eon returns the positive integer year within the active .era (e.g. 2026 in CE, 4 in 4 BCE, or 4 in Reiwa 4 when using the Japanese calendar).
  2. Astronomical Julian Day (.jj) vs. Day of Year (.doy): .jj provides 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. 2461331 for 2026-10-17). If you need the calendar day within the current year (1–366), use .doy.

⏱️ Time Properties ​

Getter / TemporalTypeDescriptionExample
.hh
zdt.hour
numberHour of the day (0–23)15
.mi
zdt.minute
numberMinutes of the hour (0–59)30
.ss
zdt.second
numberSeconds of the minute (0–59)45
.ms
zdt.millisecond
numberMilliseconds of the second (0–999)123
.us
zdt.microsecond
numberMicroseconds of the millisecond (0–999)456
.ns
zdt.nanosecond
numberNanoseconds of the microsecond (0–999)789
.ffnumberFractional seconds representation0.123456789

πŸ—“οΈ ISO Week & Day Alignments ​

Getter / TemporalTypeDescriptionExample
.yow
zdt.yearOfWeek
number4-digit ISO week-numbering year2026
.woy
zdt.weekOfYear
numberISO week number of the year (1–53)43
.dow
zdt.dayOfWeek
numberISO weekday number (1 = Mon, 7 = Sun)6
.doy
zdt.dayOfYear
numberDay of the year (1–366)297

πŸ”€ Named String Representations ​

Getter / PathTypeDescriptionExample
.mon
Enum.keyOf(Tempo.MONTHS, zdt.month)
stringFull English month name (Gregorian registry label)'October'
.mmm
Enum.keyOf(Tempo.MONTH, zdt.month)
stringShort English month name (Gregorian registry label)'Oct'
.wkd
Enum.keyOf(Tempo.WEEKDAYS, zdt.dayOfWeek)
stringFull English weekday name'Saturday'
.www
Enum.keyOf(Tempo.WEEKDAY, zdt.dayOfWeek)
stringShort English weekday name'Sat'

🌍 Regional, Timezone & System Properties ​

Getter / PathTypeDescriptionExample
.tz
zdt.timeZoneId
stringIANA Time Zone ID'Australia/Sydney'
.cal
zdt.calendarId
stringCalendar identifier [3]'iso8601', 'gregory'
.locale
intl.locale?.toString()
stringResolved canonical BCP 47 language tag'en-AU', 'en-US'
.sphere
geo.sphere
Tempo.COMPASS |
undefined
Resolved terrestrial hemisphere or compass orientation ('north', 'south', 'equator', 'east', 'west')'south'
.ts
t.epoch[timeStamp ?? 'ms']
number | bigintUnix timestamp using configured epoch unit (defaults to 'ms'; number for ss/ms/us, bigint for ns) [4]1792843200000
.iso
zdt.toInstant()
β€· .toString()
stringStandard ISO 8601 string (RFC 3339) in UTC'2026-10-24T04:30:45
.123456789Z'
.isValidbooleantrue if the underlying date-time is validtrue
  1. Active Calendar (.cal) vs. Locale Calendar Preference (.intl.info.calendar): .cal returns 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' for en-US, or 'buddhist' for th-TH), use t.intl.info.calendar.
  2. Configured Epoch Timestamp (.ts): .ts resolves its value using the configured timeStamp unit (defaults to 'ms'). Only 'ms' maps directly to native zdt.epochMilliseconds. When configured to 'ss', 'us', or 'ns', .ts maps to their respective epoch values ('ss' seconds, 'us' microseconds, or 'ns' zdt.epochNanoseconds). For an unconditional nanosecond timestamp regardless of instance configuration, use t.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.

NamespaceTypeSub-PropertiesExample Usage
.epochReadonly<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 β†’ 1792843200000
t.epoch.ns β†’ 1792843200000000000n
.intlTempoIntlNamespaceInternationalization metadata and locale engine:
β€’ .info (object) β€” cultural metadata (firstDay, weekend, calendar, minimalDays)
β€’ .locale (Intl.Locale) β€” native locale instance
t.intl.info.firstDay β†’ 1
t.intl.locale.baseName β†’ 'en-US'
.geoReadonly<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
.termTempoTermRegistryDynamic delegator accessing resolved terminology from loaded TermPlugin modulest.term.season β†’ 'summer'
t.term.quarter β†’ 'Q1'
.fmtRecord<string,
string | undefined>
Dynamic delegator evaluating named format presets from Tempo.enums.FORMAT and config.registry.formatst.fmt.date β†’ '2026-10-24'
t.fmt.display β†’ 'Sat, 24 Oct 2026'
.isTempoPredicatesLazy-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() β†’ true
t.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:

GetterTypeDescriptionExample Usage
.configReadonly<Config>Active configuration proxy reflecting resolved global defaults and local instance overrides.t.config.timeZone
.parseInternal.ParseShadowed view of internal parse state, including active mode, anchor, and matched AST tokens (.result).t.parse.anchor
t.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:

  1. 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.).
  2. Tier 2: Structured Namespaces (t.<namespace>.*)
    Domain-specific sub-properties grouped into clean namespaces (.epoch, .geo, .intl, .term, .is) to prevent flat autocomplete pollution.
  3. Tier 3: The Native Temporal Gateway (t.zdt.*)
    Standard TC39 Temporal properties (.daysInYear, .inLeapYear, .offsetNanoseconds, .hoursInDay, .monthCode) are accessed directly via .zdt with 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 on Tempo or an isolated sandbox (Tempo.extend()). Resolver functions are automatically treated as lazy, per-instance memoized getters:
    typescript
    import { 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.* or t.astro.*) with automatic proxy resolution and caching using defineNamespace.
  • Reusable Lifecycle Plugins: Package complex behaviors, prototype methods, and static tools using definePlugin.

Learn more in the comprehensive Extending Tempo with Plugins Guide.

Released under the MIT License.