Fuzzy dates module for Histograph.
One of the following:
- ISO 8601 date string (
YYYY-MM-DD):
"2007-06-12"
- Single year (string or number):
1920, "1995"
- Object with a ISO 8601 date string and an error specification:
{
date: '1962-10-10',
error: '1M'
}- Object with a year string/number and an error specification:
{
date: '1970',
error: '5y'
}- String with year and error in years, of the form
:year±:error:
"1995±5"
- Array of two years
[
1930,
1940
]- Array of two ISO 8601 date strings
[
"1912-03-04",
"1912-03-26"
]{
date: '1970',
error: '1M'
}- Date: either a year or an ISO 8601 date
- error units:
d: dayM: monthy: year
Fuzzy Dates uses Moment.js time shorthand keys (currently only days, months and years).
- Array of two ISO 8601 dates
Input:
{
year: 1915,
error: '3y'
}Output:
[
'1912-01-01',
'1918-12-31'
]
See test/testDates.js for more examples, or run npm test.
npm install --save histograph/fuzzy-dates
var fd = require('fuzzy-dates');
var a = fd.convert('1995');
console.log(a); // => ["1995-01-01", "1995-12-31"]Copyright (C) 2015 Waag Society.