Registry / productivity / ritm-date

ritm-date

JSON →
library2.2.6jsnpmunverified

A lightweight, fast date/time formatter for JavaScript/TypeScript, currently at version 2.2.6. It supports custom masks, locale-aware formatting (en, ru), timezone manipulation, date calculations, and utility methods like zeroing and validation. Key differentiators: minimal footprint, no dependencies, TypeScript-friendly, and a simple chainable API. Releases are stable with a moderate cadence, primarily bug fixes and minor enhancements.

npm install ritm-date
INSTALL
IMPORT
SIG · RITM-DATE
R
ritm-date
productivityjavascriptv2.2.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

rDate
import rDate from 'ritm-date'
const rDate = require('ritm-date')
Default ESM import; CJS require might not work in all bundlers.
rDate (TypeScript)
import rDate from 'ritm-date'
import { rDate } from 'ritm-date'
The library exposes a default export only; named import is incorrect.
import type
import type rDate from 'ritm-date'
For type-only imports, use 'import type' to avoid bundling runtime code.

Shows default format, custom mask, locale, date arithmetic, and validation.

import rDate from 'ritm-date'; // Basic usage console.log(rDate(new Date()).format()); // '01.02.2022 • 00:00' // Custom format console.log(rDate(new Date()).format('DD-MM-YY')); // '01-02-2022' // Locale console.log(rDate(new Date()).setLocale('ru').format('DD MMM YY')); // '01 Фев 2022' // Date calculation console.log(rDate(new Date()).calc(-10, 'days').format('iso')); // '2022-01-22T00:00:00+03:00' // Validation console.log(rDate().isValid('2022-02-01')); // true
Debug
Known issues
deprecatedrDate(new Date()).isValid() is deprecated. Use rDate().isValid(date) instead.
fix
Replace rDate(new Date()).isValid() with rDate().isValid(new Date()).
affects: >=2.0.0
gotchaInvalid date input returns the string 'Invalid Date' instead of throwing an error.
fix
Always use .isValid() to check before formatting.
affects: >=2.0.0
breakingIn version 2.0.0, the API changed from rDate().format() to rDate(date).format(). Old imports break.
fix
Pass the date as argument to rDate().
affects: >=2.0.0
gotchaThe 'iso' format includes timezone offset from the browser, not from the input date.
fix
Use .zone() to explicitly set timezone if needed.
affects: >=2.0.0
gotchaThe 'l' format returns a short string for comparison, but its format is not documented for consistency.
fix
For date comparison, prefer converting to timestamps with .format('x').
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: rDate is not a function
Named import instead of default import in ESM context.
fix
Use 'import rDate from 'ritm-date'' instead of 'import { rDate } from 'ritm-date''.
Uncaught TypeError: rDate(...).format is not a function
rDate() called without arguments returns a different object (deprecated usage).
fix
Pass a date to rDate(new Date()).format() or use rDate().format(date) for deprecated API.
Uncaught TypeError: Cannot read properties of undefined (reading 'format')
Input date is invalid and rDate returns undefined/proxy.
fix
Always validate input with rDate().isValid(date) before calling .format().
Upgrade
Version history
2.2.6latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
29 hits · last 30 days
node
28
OpenAI (training)
1
Resources
ritm-date — npm install ritm-date · libregistry