JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2433
  • Score
    100M100P100Q111221F
  • License ISC

Return dates and times in easily readable formats

Package Exports

  • human-date

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (human-date) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

human-date

Making dates and times readable for humans. Forks and pull requests most welcomed.

Usage

npm install human-date --save

.date(arg)

  • arg can be a date object or string that parses into a date object.
hdate.date('8-16-1987')
// August 16th, 1987

hdate.date(new Date('8-16-1987'))
// August 16th, 1987

.time(arg)

  • arg can be an integer representing seconds or a date string / object.

Note: Positive numbers represent the future and negative the past.

hdate.time(4)
// 4 seconds from now

hdate.time(-4)
// 4 seconds ago

hdate.time("8-16-1987")
// 27 years 96 days 21 hours 47 minutes 2 seconds ago

hdate.time("8-16-2020")
// 5 years 277 days 1 hours 41 minutes 43 seconds from now

hdate.time(new Date("8-16-1987"))
// 27 years 96 days 21 hours 47 minutes 2 seconds ago

.month(arg)

  • arg can be an integer representing the month or a date string / object.

Note: Month number does not start at 0. For instance 1 Represents January.

hdate.month(8)
// August

hdate.month("8-16-1987")
// August

hdate.month(new Date("8-16-1987"))
// August

Todos

  • Add various options.
  • Support different locales.
  • Proper testing framework.