v4.1 • Utils • 3kb gzipped • MIT
DateSlim
Date formatting and relative time that leans on the platform instead of shipping a locale database.

// why dateslim
The platform already knows
Built on Intl, so every locale the browser supports works without adding a byte to your bundle.
// stack
Immutable operations
Every function returns a new value. No accidental mutation of a date held somewhere else.
DateSlim started as a single file in a client project and stayed small on purpose. It does one job, it does it in 3kb gzipped, and it has no runtime dependencies.
Getting started
Install it, import it, call it:
npm i dateslim-js
Built on Intl, so every locale the browser supports works without adding a byte to your bundle.
What it does not do
It does not manage your state, style your components or ship a plugin system. Those are your decisions, and keeping them out is what keeps the bundle honest.
- Every locale, no data files
- Relative time that reads well
- MIT licensed, commercially friendly
Features
Every locale, no data files
Formatting comes from Intl, so locale coverage costs nothing.
Relative time that reads well
Chooses the unit a person would choose, not the one the arithmetic suggests.
Documented properly
Every public function has a worked example, not just a signature.
ESM and types
Ships module and CommonJS builds with hand-written type definitions and source maps.
Tree-shakes cleanly
Every export is side-effect free, so importing one function costs one function.
Tested to the edges
Ninety-eight percent branch coverage, with the awkward cases written first.
Get DateSlim v4.1
12 files • .min.js 3kb • .zip 84kb • sha384 verified
Changelog
- Duration formatting via Intl
- Relative unit selection reworked
- Tree-shakes to 900 bytes
- Reworked the public API for consistency
- Deprecated helpers removed
- Fixed a memory leak on repeated teardown
- Source maps now published with every build
// related
Related products
FormFlow
Validation and multi-step logic that works the same in React, Vue and vanilla. Your markup stays yours.
View →AuthKit
Drop-in JWT, OAuth and magic links with secure defaults and a five-minute setup.
View →PrintCanvas
Export any canvas to print-ready PNG, SVG or PDF at whatever resolution the page needs.
View →Drop it in this afternoon.
MIT licensed. Commercial friendly. Five-minute setup.