3.0.0 • Published 4 years ago

dehumanize-date v3.0.0

Weekly downloads
806
License
MIT
Repository
github
Last release
4 years ago

dehumanize-date

Parse dates in all the formats humans like to use:

  • today/tomorrow/yesterday
  • next/this/last Wednesday
  • 12th January
  • 12th January 1950
  • 09-08-2008
  • 2008-08-09

Return dates in just the format that computers should use:

  • 2008-08-09

Build Status Dependency Status NPM version

testling badge

Installation

$ npm install dehumanize-date

Usage

A simple function which takes a string as an argument and returns a string in the form yyyy-mm-dd.

var date = dehumanizeDate(userInput);

The second parameter contains options. You can set whether to use US-style short dates, you can change what 'now' is for input like 'yesterday', and you can change the cutoff for 2-digit years that determines whether a given two-digit year is in the 21st or 20th century.

var date = dehumanizeDate(userInput, {usa: true, now: new Date(), cutoff: 80});

If you just want to use US formats for numerical dates you can also pass true as the second parameter:

var date = dehumanizeDate(userInput, true);

License

MIT

3.0.0

4 years ago

2.6.2

6 years ago

2.6.1

6 years ago

2.6.0

6 years ago

2.5.0

7 years ago

2.4.0

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

11 years ago

1.1.0

11 years ago

1.0.0

11 years ago

0.0.1

11 years ago