The Temporal namespace provides typed access to Temporal classes with intelligent fallback.
namespace Temporal { type Duration = TemporalImplementation.Duration; type Instant = TemporalImplementation.Instant; type PlainDate = TemporalImplementation.PlainDate; type PlainDateTime = TemporalImplementation.PlainDateTime; type PlainMonthDay = TemporalImplementation.PlainMonthDay; type PlainTime = TemporalImplementation.PlainTime; type PlainYearMonth = TemporalImplementation.PlainYearMonth; type TimeZone = TemporalImplementation.TimeZone; type ZonedDateTime = TemporalImplementation.ZonedDateTime; const Duration: TemporalImplementation.Duration; const Instant: TemporalImplementation.Instant; const PlainDate: TemporalImplementation.PlainDate; const PlainDateTime: TemporalImplementation.PlainDateTime; const PlainMonthDay: TemporalImplementation.PlainMonthDay; const PlainTime: TemporalImplementation.PlainTime; const PlainYearMonth: TemporalImplementation.PlainYearMonth; const TimeZone: TemporalImplementation.TimeZone; const ZonedDateTime: TemporalImplementation.ZonedDateTime;}The Temporal namespace provides typed access to Temporal classes with intelligent fallback.
This namespace automatically detects and uses the best available Temporal implementation:
setTemporal())import { Temporal, hasTemporal } from '@agape/temporal';
if (hasTemporal()) {
const now = Temporal.PlainDateTime.from('2025-09-19T10:00');
console.log(now.toString());
}
import { Temporal, TemporalNotAvailableError } from '@agape/temporal';
try {
const date = Temporal.PlainDate.from('2025-09-19');
} catch (error) {
if (error instanceof TemporalNotAvailableError) {
console.error('Temporal is not available:', error.message);
}
}
import type { Temporal as TemporalPolyfill } from "@js-temporal/polyfill";
(globalThis as any)['Temporal'] = TemporalPolyfill;
import { Temporal, hasTemporal } from '@agape/temporal';
Temporal.PlainDateTime === TemporalPolyfill.PlainDateTime;
import type { Temporal as TemporalPolyfill } from "@js-temporal/polyfill";
import { Temporal, setTemporal } from '@agape/temporal';
setTemporal(TemporalPolyfill)
Temporal.PlainDateTime === TemporalPolyfill.PlainDateTime;
