5.1.2 • Published 2 years ago

rel-time-format v5.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

🕰️ rel-time-format

JavaScript library for human-friendly relative date formatting.

This is a simple wrapper for Intl.RelativeTimeFormat.

version build workflow codecov MIT license semantic-release: angular

Installation

Using npm:

npm install rel-time-format

Using yarn:

yarn add rel-time-format

Usage

Important

import { getRelTime } from 'rel-time-format';

getRelTime(new Date(), new Date(), {
  locales: 'en',
  numeric: 'auto',
});
//=> now

getRelTime(new Date(2023, 0, 1), new Date('2022-12-01'), {
  locales: 'ru',
  style: 'short',
});
//=> через 1 мес.
import { getRelYears } from 'rel-time-format';

getRelYears(new Date('2000 Jan 1'), new Date('2022-01-01'), { locales: 'en' });
//=> 22 years ago
import { getDiffInCalendarDays } from 'rel-time-format';

getDiffInCalendarDays(
  new Date('2022-01-01'),
  new Date('2022-01-02T23:59:59'),
  true
);
//=> 1

Documentation

Check out the documentation website.

Support

  • Node.js >= 14
  • Chrome >= 71
  • Edge >= 79
  • Firefox >= 65
  • Opera >= 68
  • Safari >= 14

License

MIT

5.1.2

2 years ago

5.1.1

2 years ago

5.1.0

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago

3.0.0

2 years ago

4.1.0

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.2

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago