1.0.1 • Published 9 months ago

@eli-90/date-lab v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Date Library Documentation

License: MIT

npm version

Visit the date library on npm

Bundle Size

GitHub issues

The D class is a utility for working with date instances and formatting.

Constructor

constructor(...args)

Creates a new D instance with a date.

  • ...args (optional): Arguments to create a new Date instance.

Properties

year

Returns the full 4-digit year of the date.

yr

Returns the 2-digit year (without century) of the date.

month

Returns the full name of the month.

mon

Returns the abbreviated name of the month (first 3 letters).

day

Returns the full name of the day of the week.

dy

Returns the abbreviated name of the day of the week (first 3 letters).

date

Returns the date of the month.

hours

Returns the hours of the date.

mins

Returns the minutes of the date.

secs

Returns the seconds of the date.

Methods

format(format)

Formats the date instance according to the provided format string.

  • format (string): The format string specifying how to format the date.

when()

Calculates and returns a human-readable description of the time difference between the date instance and today's date.

Example Usage

const instance = new D(2023, 8, 30);
const formattedDate = instance.format('YYYY-MM-DD');
const timeDifference = instance.when();

console.log(formattedDate); // Outputs: 2023-09-30
console.log(timeDifference); // Outputs: "1 day from now"
babel-plugin-istanbulanymatchansi-regexbabel-jestbabel-preset-jestbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbrace-expansionbalanced-matchbrowserslistbraceschalkbserbuffer-fromchar-regexci-infocallsitescaniuse-litecocliuicolor-namecolor-convertcollect-v8-coveragedebugconcat-mapcamelcaseansi-escapesdedentemitterycjs-module-lexerdeepmergeemoji-regexdiff-sequencesesprimaescape-string-regexpescaladedetect-newlineconvert-source-mapexpectcross-spawnfill-rangefind-upexecafast-json-stable-stringifyfseventsexitget-caller-filefunction-bindgensyncfb-watchmanglobgraceful-fsfs.realpathhuman-signalsansi-stylesglobalsget-streamhas-flaghashtml-escaperinheritsinflightis-arrayishimport-localimurmurhashistanbul-lib-coverageis-core-moduleistanbul-lib-reportis-numberistanbul-reportsis-generator-fnget-package-typejest-circusjest-changed-filesjest-clijest-diffis-fullwidth-code-pointjest-docblockistanbul-lib-source-mapsjest-configistanbul-lib-instrumentjest-haste-mapjest-get-typejest-message-utiljest-environment-nodeis-streamjest-regex-utiljest-matcher-utilsjest-mockjest-eachjest-resolvejest-runnerjest-pnp-resolverjest-resolve-dependenciesisexejest-runtimejest-leak-detectorjest-watcherjest-validatejsescjs-tokensjest-workerjest-snapshotjson-parse-even-better-errorslines-and-columnsjest-utillevenlru-cachemakeerrormerge-streamkleurmicromatchlocate-pathmake-dirjson5minimatchnatural-comparejs-yamlonceonetimenode-releasesnormalize-pathp-limitnpm-run-pathp-locatepath-existsmsparse-jsonp-trymimic-fnpkg-dirpath-is-absolutenode-int64piratespretty-formatpicomatchpure-randpath-keypicocolorsreact-isrequire-directorypath-parseresolve-fromresolve-cwdsemverresolve.exportssignal-exitshebang-commandresolvesource-map-supportshebang-regexstack-utilssource-mapslashstring-lengthpromptsstrip-bomstring-widthsprintf-jsstrip-json-commentssupports-colorstrip-ansisisteransitmplto-fast-propertiestest-excludeto-regex-rangeelectron-to-chromiumsupports-preserve-symlinks-flagwalkerupdate-browserslist-dbtype-detectstrip-final-newlinewrap-ansitype-festwrite-file-atomicyargs-parseryallistwrappyy18nyargsargparseerror-exwhichyocto-queuev8-to-istanbul
1.0.1

9 months ago

1.0.0

9 months ago