1.0.3 • Published 2 years ago

@alxrg/date-maker v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Date-Maker - NPM Date Library

npm

Allows you to quickly transform the javascript date to human readable strings

Installation

Use the package manager npm to install.

npm i @alxrg/date-maker

Link to npm library

Usage

const D = require("../src/index.js");
const dateTesting = new D(2022, 0, 8, 8, 4, 6);
const testDate = new D(2022, 10, 30, 6, 7, 8);
const testToday = new D();

// Full year
dateTesting.year; // 2022
// Short year
dateTesting.yr; // 22

// Full month
dateTesting.month; // 'January'
// Short month
dateTesting.mon; // 'Jan'

// Full day
dateTesting.day; // 'Saturday'
// Short day
dateTesting.dy; // 'Sat'

// Date Number
dateTesting.date; // 8

// Hour Number
dateTesting.hours; // 8
// Hour Padded (string)
dateTesting.hoursPadded; // '08'

// Minute Number
dateTesting.mins; // 4
// Minute Padded (string)
dateTesting.minsPadded; // '04'

// Second Number
dateTesting.secs; // 6
// Second Padded (string)
dateTesting.secsPadded; // '06'

// Examples of some formated dates
testDate.format("y/m/d"); // '22/Nov/Thu'
testDate.format("H:I:S"); // '06:07:08'
testDate.format("h:i:s"); // '6:7:8'
testDate.format("Y-M-D h:I:S"); // '2022-November-Thursday 6:07:08'

// Use the .when() will return the difference in time between two dates
const mockDate = new Date(2022, 10, 4);
dateTesting8.when(mockDate); // '16 days from now'
dateTesting7.when(mockDate); // '7 days ago'
dateTesting.when(mockDate); // '1 month 2 days from now'
dateTesting6.when(mockDate); // '9 months 29 days ago'
dateTesting5.when(mockDate); // '5 years 7 month 22 days from now'
dateTesting2.when(mockDate); // '12 years 10 month 3 days ago'
testToday.when(new Date()); // 'today'

Testing

The tests are running correctly = To run tests:

npm test

To check code test coverage:

npx jest --coverage

License

MIT

ansi-escapesansi-regexansi-stylesanymatchbabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbabel-preset-jestbracesbrowserslistbserbuffer-fromargparsecallsitescaniuse-litechalkchar-regexci-infobalanced-matchcliuicobrace-expansioncolor-convertcolor-nameconcat-mapconvert-source-mapcamelcasecjs-module-lexerdebugdedentcollect-v8-coveragedetect-newlinediff-sequenceselectron-to-chromiumemitteryerror-exemoji-regexescaladeescape-string-regexpdeepmergecross-spawnexecaesprimaexpectfast-json-stable-stringifyfill-rangefind-upfseventsfunction-bindgensyncget-caller-filefb-watchmanfs.realpathget-package-typeexitgraceful-fsglobalshashas-flagglobhtml-escaperhuman-signalsget-streamimport-localimurmurhashis-arrayishis-core-moduleis-fullwidth-code-pointis-generator-fnis-numberinheritsisexeis-streaminflightistanbul-lib-reportistanbul-lib-instrumentistanbul-lib-source-mapsistanbul-lib-coveragejest-circusjest-clijest-configjest-diffjest-eachjest-docblockjest-environment-nodejest-get-typejest-haste-mapjest-matcher-utilsjest-message-utiljest-mockjest-changed-filesistanbul-reportsjest-regex-utiljest-resolvejest-runnerjest-runtimejest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-tokensjest-pnp-resolverjest-resolve-dependenciesjest-leak-detectorjs-yamljsescjson-parse-even-better-errorslines-and-columnslocate-pathlru-cachekleurlevenmakeerrormerge-streammake-dirmicromatchjson5msnatural-comparenode-releasesnormalize-pathmimic-fnnpm-run-pathnode-int64minimatchp-limitp-locatep-tryparse-jsonpath-existsoncepath-is-absoluteonetimepath-keypicomatchpiratespkg-dirpretty-formatreact-isrequire-directoryresolveresolve-cwdresolve-fromresolve.exportssafe-buffersemvershebang-commandpicocolorspromptspath-parsesignal-exitslashsource-map-supportsource-mapstack-utilsstring-lengthstring-widthstrip-ansistrip-bomsprintf-jsstrip-json-commentsshebang-regexstrip-final-newlinesisteransisupports-hyperlinkssupports-colorterminal-linktmplto-fast-propertiesto-regex-rangetype-detecttest-excludetype-festsupports-preserve-symlinks-flagupdate-browserslist-dbwalkerwrap-ansiwrite-file-atomicy18nyallistyargsyargs-parseryocto-queuewrappyv8-to-istanbulwhich
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago