edtfy is a javascript tool that attempts to parse a user input and transforms it into the Extended Date/Time Format format.
The following forms of dates are currently supported: date, interval, uncertain/approximate, season, one of a set, multiple dates.
View code on github
Usage
Install:
npm install edtfy # npm
bowser install edtfy # bower
And use:
const edtfy = require('edtfy');
edtfy.locale('en');
edtfy('around march 1988'); // 1988-03~
Features
Date
A basic date can be either defined by a year, a month and a year, or a day, a month, and a year.
Recognized formats for days: D, DD, Do.
Recognized formats for months: M, MM, MMM, MMMM.
Recognized format for year: YYYY.
Interval
An interval is a period of time represented by a start date and an end date.
Start and end dates are dates can be either a date or any date format described above, uncertain/approximate, unspecified, season, or various.
Uncertain and approximate
The parser will look for terms as around or about that indicates the dates is approximate, or a ? sign, for an uncertain date. A date can be both uncertain and approximate.
Unspecified
The characters u and * indicate that the value of the digit is unknown.
Season
The parser finds seasons, if they are used in combination with a year.
One of a set
The parser finds sets of dates, when these ones are separated by the or keyword. A set member can be as specified in date, uncertain/approximate, unspecified, season, or various.
Multiple dates
The same way as sets, the parser finds multiple dates, when these ones are separated by the and keyword. These dates can be as specified in date, uncertain/approximate, unspecified, season, or various.
Various
The parser handles centuries, as well as 5digits long numbers.