###date-cruncher
date-cruncher is a string-centric date calculator class.
###installation
npm i --save typescript-collections
npm i --save date-cruncher
###example usage
A live example is available on tonic
import {DateCruncher as dc} from 'date-cruncher';
let date: Date = dc.evaluate('10/07/2016 + 1 day round up');
date = dc.evaluate('10/07/2016 + 1 day round up', (e) => { console.log(e); });
date = dc.evaluate('10/07/2016 + 1 day round up', (e) => { console.log(e); });
date = dc.evaluate('10/07/2016 + 3 business days');
date = dc.evaluate('10/07/2016 third thursday');
date = dc.evaluate('10/07/2016 2nd fri');
date = dc.evaluate('10/07/2016 first tue');
date = dc.evaluate('10/07/2016 last thursday');
###fyi
####no locale support
this lib does not support locales. it only supports U.S. dates and holidays.
avoid saying:
import {DateCruncher as dc} from 'date-cruncher';
let d = new Date();
let expression = d.toLocaleDateString() + ' 3rd wednesday';
internet explorer 11 likes to throw in U+200E text-direction marks around the month day and year and date-cruncher doesn't accommodate this behavior.
instead, say:
import {DateCruncher as dc} from 'date-cruncher';
let d = new Date();
let expression = dc.resolveDateString(d) + ' 3rd wednesday';