|
|
|
A library of highly granular, fully tree-shakeable utility functions built directly on top of the JavaScript Temporal API.
This package provides a bridge for developers transitioning from legacy date wrappers (like Moment or date-fns) into the modern Temporal API.
Why tempo-fns?
- Tree-shakeable: Import exactly what you need.
import { isFirstDayOfMonth } from '@magmacomputing/tempo-fns'pulls in zero extra bloat. - Native Temporal: Functions accept native
Temporal.ZonedDateTimeandTemporal.PlainDateobjects. You don't have to use theTempoclass. - Synergy: If you do use the
Tempoclass wrapper,tempo-fnsprovides advanced business-intelligence utilities that inherently understand Tempo's Terms engine (e.g.,isSameFiscalQuarter).
Usage (NPM / Modern Bundlers)
import { Tempo } from '@magmacomputing/tempo';
import { isFirstDayOfMonth, isSameFiscalQuarter } from '@magmacomputing/tempo-fns';
const today = new Tempo();
if (isFirstDayOfMonth(today)) {
console.log('Rent is due!');
}
Usage (Static CDN / Browser Global)
If you aren't using a bundler (like Vite, Webpack, or Rollup), we provide a pre-bundled script that exposes a Functions global object.
<script src="https://cdn.jsdelivr.net/npm/@magmacomputing/tempo-fns/dist/tempo-fns.global.js"></script>
<script>
// Access functions via the Functions global
Functions.isFirstDayOfMonth(Temporal.Now.plainDateISO());
</script>