tiempo - Timezone-Safe Datetime Handling
Lightweight utility library for timezone conversions built on the Temporal API.
npm install @gobrand/tiempo
Best Practices
- Always use explicit timezones - Never rely on implicit timezone behavior. details
- Don't use JavaScript Date - Use tiempo instead of Date for timezone work. details
- Store UTC, display local - Backend stores UTC, frontend converts for display. details
Conversion
| Function | Description | Reference |
|---|
toZonedTime() | Convert to a timezone-aware ZonedDateTime | details |
toPlainTime() | Parse a plain time or extract wall-clock time from a datetime | details |
toPlainDate() | Parse a plain date or extract calendar date from a datetime | details |
toUtc() | Convert to a UTC Instant | details |
toIso() | Convert to an ISO 8601 string | details |
toIso9075() | Convert to ISO 9075 (SQL) format string | details |
toDate() | Convert to a JavaScript Date object | details |
Current Time
| Function | Description | Reference |
|---|
now() | Get the current date and time as a ZonedDateTime | details |
today() | Get today's date as a PlainDate | details |
Formatting
| Function | Description | Reference |
|---|
format() | Format a datetime using date-fns-like format tokens | details |
formatPlainDate() | Format a Pl... | |