@iguanads/tempo
v1.2.0
Published
Iguana Design System - Tempo - by Bento
Readme
Iguana DS Bento - Tempo
Date/time utility library for the Iguana Design System. A wrapper around dayjs with timezone and UTC plugins.
Installation
pnpm add @iguanads/tempoConfiguration
Create a config file in the root of your project (e.g., tempo.config.ts):
import { tempo } from '@iguanads/tempo'
import { timezone, utc } from '@iguanads/tempo/plugins'
tempo.extend(utc)
tempo.extend(timezone)Usage
import { tempo } from '@iguanads/tempo'
tempo() // current date as Tempo object
tempo(new Date()) // from Date
tempo(new Date()).tz('America/Cayman') // with timezone
tempo('2022-06-10').format('YYYY-MM-DD') // formattingUtilities
import { intervalToDuration, formatDistanceToNow } from '@iguanads/tempo'
// Calculate duration between two dates
intervalToDuration({ start: '2024-01-01', end: '2024-06-01' })
// Format relative distance ("Now", "5 min ago", "10 Jan")
formatDistanceToNow(tempo('2024-01-15'))Commands
Development
pnpm devBuild
pnpm buildLint
pnpm lint