2.0.2 • Published 4 months ago

ritm-date v2.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

ritm-date

npm version

Really lightweight, fast date & time formatter. Typescript friendly

  1. npm install ritm-date
  2. import rDate from 'ritm-date' at your .js/.ts file
  3. use it
rDate(new Date()).format()
// Output: '01.02.2022 • 00:00'

rDate('2022-02-01T00:00:00+03:00').format()
// Output: '01.02.2022 • 00:00'

rDate(new Date()).format('iso')
// Output: '2022-02-01T00:00:00+03:00'

rDate(new Date()).format('DD-MM-YY')
// Output: '01-02-2022'

rDate(new Date()).setLocale('ru').format('DD MMM YY')
// Output: '01 Фев 2022'

rDate(new Date()).setLocale('en').format('DD MMM YY')
// Output: '01 Feb 2022'

rDate(new Date()).setLocale('en').format('DD ** MMMM ** YY')
// Output: '01 ** February ** 2022'

rDate(new Date()).format('DD*MM&YY::HH:mm')
// Output: '01*02&22::00:00'

rDate(new Date()).calc(-10, 'days').calc(1, 'hour').format()
// You can use day/days, hour/hours, minute/minutes
// Output: '22.01.2022 • 02:00'

rDate('2022-02-01T12:34:56+03:00').zeroing().format('iso')
// Zeroing time
// Output: '2022-02-01T00:00:00+03:00'

rDate(new Date()).zone(1).format('iso')
// Output: '2022-01-31T20:00:00-01:00'

rDate(new Date()).format('x')
// Output: 1643662800000 <-- Timestamp

rDate(new Date()).format('l')
// Short format, e.g. for comparing dates
// Output: 1/2/22 <-- Timestamp

rDate(new Date()).isValid()
// Output: true

rDate(new Date('grrr!')).isValid()
// Output: false

rDate('string').isValid()
// Output: false

Utils

Locales: en/ru

Available abbreviations for masks: YYYY, YY, MMMM, MMM, MM, M, DD, D, dd, ddd, HH, h, mm, ss

1.1.8

8 months ago

1.1.7

8 months ago

1.3.2

4 months ago

1.3.1

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago