datetick
v1.2.0
Published
DateTick — a tiny, immutable, fully timezone-aware date toolkit: formatting, parsing, durations and live relative-time, for any framework.
Maintainers
Readme
DateTick parses, validates, manipulates, formats and compares dates and times — with every calendar operation resolved through a real IANA timezone, so one absolute instant is always interpreted consistently in one zone (DST included). Zero runtime dependencies. Works the same in vanilla JS, Angular, React, Vue and Node.
import datetick from 'datetick';
datetick('2026-06-25T19:23Z', { timezone: 'Asia/Tokyo' }).formatPattern('DD/MM/YYYY HH:mm'); // '26/06/2026 04:23'
datetick('2026-06-25').startOf('month').add(1, 'day').set('year', 2027).format('long');
datetick.duration(90, 'minute').humanize(); // '2 hours'
datetick('2026-06-25').timeAgoLive().subscribe(console.log); // live "time ago" stream- 🌐 Fully timezone-aware — reading components,
add/subtract,startOf/endOf, weeks and formatting all resolve through the configured IANA timezone - 💪 Immutable & chainable — every method returns a new instance; safe to share across Angular components, React renders and Vue computeds
- 📦 Zero runtime dependencies — locales come from the platform's
Intl, so there are no locale files to import - 🕒 Familiar API — Day.js-style tokens, getters/setters, comparisons and relative time
- ⏳ Durations & live "time ago" — ISO 8601 durations,
humanize(), and a dependency-free live relative-time stream - 🗓️ Calendar-grid data — ready-to-render month grids for building date pickers
- 🔒 TypeScript-first — full types shipped, ESM + UMD builds
Getting Started
Installation
npm install datetickLive demo & documentation
The full API reference — getters/setters, manipulation, comparisons, formatting/parsing tokens, durations, calendar-grid data, app-wide locale defaults, and copy-paste Angular / React / Vue integration (including a runtime language switcher) — plus a live in-browser playground, is hosted on GitHub Pages:
➡️ andreasnicolaou.github.io/datetick
You can also open docs/index.html directly in a browser — no build step required.
API
It's easy to use DateTick to parse, validate, manipulate and display dates and times.
datetick('2026-08-08'); // parse
datetick().format('YYYY-MM-DD HH:mm:ss'); // display (token pattern)
datetick().format('long'); // display (Intl preset)
datetick().set('month', 3).month(); // get & set
datetick().add(1, 'year').subtract(3, 'day'); // manipulate
datetick().isBefore(datetick()); // query
datetick('2026-06-25').isBetween('2026-06-01', '2026-07-01', '[)');Timezones
Every operation is resolved through the configured timezone, so the same instant is interpreted consistently — across DST transitions too.
const t = datetick('2026-06-25T19:23Z', { timezone: 'Asia/Tokyo' });
t.hour(); // 4 (wall-clock hour in Tokyo)
t.utc().hour(); // 19 (same instant, UTC)
t.utcOffset(); // 540Locale-aware, without locale files
Locales resolve through the platform's Intl, so nothing extra needs to be imported.
datetick('2026-06-25', { locale: 'fr' }).format('long'); // French
datetick('2026-06-25', { locale: 'fr' }).localeData().months()[0]; // 'janvier'App-wide defaults
Bind locale / timezone / week start once and reuse the scoped factory — no global mutation.
const paris = datetick.withDefaults({ locale: 'fr', timezone: 'Europe/Paris' });
paris('2026-06-25').format('long'); // French, Paris
datetick('2026-06-25').format('long'); // unaffectedLicense
DateTick is licensed under the MIT License © Andreas Nicolaou.
