fuzzy-dates
v0.0.2
Published
Fuzzy dates module for Histograph
Downloads
1
Readme
Fuzzy Dates
Fuzzy dates module for Histograph.
Input
One of the following:
- ISO 8601 date (
YYYY-MM-DD
, for example2007-06-12
) - Year (string or number)
- ISO 8601 date with error specification
- Year with error specification
- Array of two years
- Array of two ISO 8601 dates
Error specification
{
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).
Output
- Array of two ISO 8601 dates
Example
Input:
{
year: 1915,
error: '3y'
}
Output:
[
'1912-01-01',
'1918-12-31'
]
See test/testDates.js
for more examples, or run npm test
.
Installation
npm install --save histograph/fuzzy-dates
Usage
var fd = require('fuzzy-dates);
var a = fd.convert('1995');
console.log(a);
// ["1995-01-01", "1995-12-31"]