Skip to content

API Reference

Atemporal provides a comprehensive and type-safe API for date-time manipulation, built on top of the modern Temporal API.

Core API

Static Utilities

The atemporal factory object exposes static utility methods beyond instance creation:

Creators

MethodDescription
atemporal()Create current date/time instance
atemporal(input, tz?)Create from any DateInput
atemporal.from(input, tz?)Alias for atemporal(input, tz?)
atemporal.unix(seconds)Create from Unix timestamp (seconds)
atemporal.duration(like)Create a Temporal.Duration from an object or ISO string

Validation

MethodDescription
atemporal.isValid(input)Check if input can be parsed to a valid date
atemporal.isAtemporal(input)Type guard: check if input is a TemporalWrapper instance
atemporal.isDuration(input)Type guard: check if input is a Temporal.Duration
atemporal.isValidTimeZone(tz)Validate IANA time zone string
atemporal.isValidLocale(code)Validate locale identifier
atemporal.isPlugin(input)Check if value is a valid atemporal plugin

Comparison

MethodDescription
atemporal.min(...dates)Return the earliest date from a list
atemporal.max(...dates)Return the latest date from a list

Configuration

MethodDescription
atemporal.setDefaultLocale(code)Set the default locale for all new instances
atemporal.setDefaultTimeZone(tz)Set the default IANA time zone
atemporal.getDefaultLocale()Get the current default locale
atemporal.getTemporalInfo()Get info about the Temporal implementation ({ isNative, environment, version })

Plugin Management

MethodDescription
atemporal.extend(plugin, options?)Register and apply a plugin
atemporal.lazyLoad(name, options?)Lazy-load a plugin on demand (async)
atemporal.lazyLoadMultiple(names, options?)Lazy-load multiple plugins (async)
atemporal.isPluginLoaded(name)Check if a plugin has been loaded
atemporal.getLoadedPlugins()Get list of loaded plugin names
atemporal.getAvailablePlugins()Get list of all plugins available for lazy loading

Plugins

For extended functionality like relative time (.fromNow()), business day calculations, or appointment slots, check out the Plugins section.