TS-JS Date Library
A simpler Date library for Javascript.
Installation
Use the package manager npm to install.
npm i ts-date-library
Link to npm library
Usage
const { D } = require('ts-date-library');
const testDate = new D(2022, 9, 22, 3, 4, 5);
const testDate2 = new D('6/1/1982');
const testDateToday = new D();
testDate.year
testDate2.year
testDate.yr
testDate2.yr
testDate.month
testDate2.month
testDate.mon
testDate2.mon
testDate.day
testDate2.day
testDate.dy
testDate2.dy
testDate.date
testDate2.date
testDate.hours
testDate2.hours
testDate.mins
testDate2.mins
testDate.secs
testDate2.secs
testDate.format('Y-M-D h:I:S')
testDate.format('h:i:s')
testDate.format('h/i/s')
testDate2.format('y-m-d H:I:S')
testDate2.format()
const mockDate = new Date(2022, 6, 6);
testDate.when(mockDate)
testDate2.when(mockDate)
testDate3.when(mockDate)
testDate5.when(mockDate)
testDate6.when(mockDate)
testDate7.when(mockDate)
testDate8.when(mockDate)
testDateToday.when(new Date())
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Testing
To run tests:
npm test
To check code test coverage:
npx jest --coverage
License
MIT