|
|
TempoThe Professional Date-Time Library for the Temporal API |
Tempo is a premium, high-performance wrapper for the ECMAScript Temporal API. Designed for professionals, it combines immutable state-management with a fluent, natural-language engine. It is the modern, type-safe successor to legacy libraries like Moment.js and Luxon.
import { Tempo } from '@magmacomputing/tempo';
import { AstroPlugin } from '@magmacomputing/tempo-plugin-astro';
// π Instantly Extensible (with deterministic defaults)
Tempo.init({
plugins: [AstroPlugin],
timeZone: 'America/New_York'
});
// π― Natural Language Parsing (Deterministic anchor)
const event = new Tempo('next Friday 3pm', { anchor: '2026-10-15' });
// π Fluent Mutations (Immutable)
const reminder = event.add({ hours: 2 }).set({ minute: 0 });
// β³ Comparative Durations
const diff = event.until('2026-12-25');
console.log(diff.iso); // P2M2D
// π Beautiful Formatting
console.log(event.format('{mon} {dd:ord}, {yyyy}')); // October 23rd, 2026
// π Domain Logic (via Plugin)
console.log(event.term.astronomy.season); // 'Autumn'
npm install @magmacomputing/tempo # npm
yarn add @magmacomputing/tempo # yarn
pnpm add @magmacomputing/tempo # pnpm
bun add @magmacomputing/tempo # bun
deno add npm:@magmacomputing/tempo # deno
For standard usage natively in the browser, use the pre-optimized Global ESM Bundle. It includes the entire core engine in a single file:
<script type="importmap">
{
"imports": {
"@js-temporal/polyfill": "https://cdn.jsdelivr.net/npm/@js-temporal/polyfill@0.5.1/dist/index.esm.js",
"@magmacomputing/tempo": "https://cdn.jsdelivr.net/npm/@magmacomputing/tempo@3/dist/tempo.bundle.esm.js"
}
}
</script>
<script type="module">
import '@js-temporal/polyfill';
import { Tempo } from '@magmacomputing/tempo';
const t = new Tempo('next Friday');
</script>
Advanced Usage (Tempo Plugins & CDNs) If you need to use Tempo Premium Plugins natively in the browser, require granular module resolution, or want to use on-the-fly bundling CDNs (like
esm.sh), please see our comprehensive Installation Guide for detailed import map configurations.
While the native Temporal API gives you perfect primitives (ZonedDateTime, PlainDate), it doesn't give you business logic. Tempo bridges that gap.
| Feature | Native Temporal API |
The Tempo Ecosystem |
|---|---|---|
| Primitives | Perfect (Instant, ZonedDateTime) |
Powered by Native Primitives β¨ |
| Timezones | IANA String Support | Advanced fallback & auto-syncing |
| Domain Logic | β Build it yourself | β
Plugins (astro, sync) |
| Natural Language | β Manual parsing | β "next Friday 3pm" |
Temporal proposal. Inherit the reliability of the future standard.astro) and atomic state syncing (sync).Intl APIβno massive static locale dictionaries required.Temporal polyfill adds weight today, it can be dropped entirely the moment JavaScript environments natively adopt the Stage 4 standard.For a deeper dive into the API, architecture, and advanced features:
Tempo is the core library, but the ecosystem extends further:
| Package | Description | Resources |
|---|---|---|
@magmacomputing/tempo |
Core library β parsing, formatting, natural-language engine | |
@magmacomputing/tempo-fns |
Pure functional utilities built on native Temporal & Tempo β tree-shakeable helpers | |
@magmacomputing/tempo-plugin-* |
Premium & community plugins β Ticker, Astro, Finance, Sync, Snap and more |
hello@magmacomputing.com.au.π Premium! Β | Β β Loving it! Β | Β π‘ Needs work Β | Β π Found a bug
Distributed under the MIT License. See LICENSE for more information.