Changelog - 2026-10-14
TemporalHelper runs in every browser and speaks a locale
FeatureIn one line. A browser app can drop dayjs: TemporalHelper now covers names, relative time and comparisons, without needing Temporal.
typescript
import { TemporalHelper, TemporalUnits } from '@venizia/ignis-helpers/temporal';
const temporal = new TemporalHelper({ timeZone: 'Asia/Ho_Chi_Minh', locale: 'vi-VN' });
temporal.format({ value: order.createdAt, pattern: 'dddd, D MMMM YYYY hh:mm A' }); // 'Thứ Bảy, 19 Tháng 9 2026 12:00 CH'
temporal.relative({ value: order.createdAt }); // '3 giờ trước'
temporal.relative({ value: order.createdAt, unit: TemporalUnits.DAY, numeric: 'auto' }); // 'Hôm qua'
temporal.diff({ value: end, other: start, unit: TemporalUnits.MONTH }); // whole months
temporal.tryParse({ value: input }); // a Date, or null
temporal.formatDuration({ milliseconds: 91_800_000 }); // '1d1h30m'What changed
- A browser-safe adapter.
IntlTemporalAdapterreads offsets throughIntl.DateTimeFormatalone. A helper built without anadapterusesTemporalwhere the runtime has it andIntlTemporalAdaptereverywhere else. Before,new TemporalHelper()threw in a browser withoutTemporal. - Writing in a locale. The constructor takes
locale(defaulten-US); every call can pass its own. New format tokens:MMMM/MMM(month name),dddd/ddd(weekday name),hh/hwithA/a(12-hour clock and AM/PM),L/LL(the date in the locale's numeric order / long form).formatIntl({ value, options })takes anyIntl.DateTimeFormatoptions in the helper's zone. - New methods:
relative({ value, base, unit, numeric }),diff({ value, other, unit })(whole units, truncated;diff(add(x, n), x)isn, outside a zone that skipped a whole day),compare({ value, other, unit })(-1,0or1),tryParse(...)andisValid({ value })(null/falsewhereparsewould throw a 400), anddurationParts({ milliseconds })/formatDuration(...)(1d1h30m, or the locale's unit words). - The new name tokens write only.
parsestays numeric and strict, and a parse pattern holding one throws a 500.
Who is affected
- A browser app on a runtime without
Temporal. It now works throughIntl. Nothing to change. - A pattern with
MMM,MMMMordddd. Formatting used to throw an "unknown token" 500; it now writes the name. As a parse pattern it still throws. - Everyone else. No change.