1.1.1 • Published 8 months ago

@sharshar/date-lib v1.1.1

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

Date Lib - Simple Date Manipulation Class

npm package link

The D class is a simple date manipulation class. It provides a set of methods and properties to retrieve various date-related information and format dates according to different masks.

Table of Contents

Installation

You can use the D class in your JavaScript project by including the index.js file in your project's source code or by installing it as a Node.js module.

Node.js Module Installation:

To use D as a Node.js module, you can install it using npm (Node Package Manager). Open your terminal and run the following command:

npm install @sharmaineb/acs3310-date-lib

## Usage

After including or installing the `D` class, you can create instances of it to work with dates and times.

Here's how you can use the `D` class:

```javascript
// Import the D class
const D = require('d');

// Create a new D instance with the current date and time
const currentDate = new D();

// Access properties to retrieve date-related information
console.log(`Full year: ${currentDate.year}`);
console.log(`Short year: ${currentDate.yr}`);
console.log(`Full month: ${currentDate.month}`);
console.log(`Short month: ${currentDate.mon}`);
console.log(`Full day: ${currentDate.day}`);
console.log(`Short day: ${currentDate.dy}`);
console.log(`Date: ${currentDate.date}`);
console.log(`Hour: ${currentDate.hours}`);
console.log(`Minutes: ${currentDate.mins}`);
console.log(`Seconds: ${currentDate.seconds}`);

// Format dates using custom masks
console.log(`Formatted Date: ${currentDate.format('Y-M-D H:I:S')}`);

// Get a description of how long ago or in the future a date is
console.log(`Time Difference: ${currentDate.when()}`);

Properties

The D class provides the following properties:

  • year: Gets the full year (e.g., 2023).
  • yr: Gets the short year (e.g., 23).
  • month: Gets the full month name (e.g., January).
  • mon: Gets the abbreviated month name (e.g., Jan).
  • day: Gets the full day name (e.g., Sunday).
  • dy: Gets the abbreviated day name (e.g., Sun).
  • date: Gets the day of the month.
  • hours: Gets the hour of the day.
  • mins: Gets the minutes.
  • seconds: Gets the seconds.

Methods

The D class provides the following methods:

  • format(mask): Formats the date according to the specified mask.
  • when(): Returns a description of how long ago or in the future the date is.

Examples

Here are some example usages of the D class:

// Create a new D instance with a specific date and time
const customDate = new D(2023, 0, 1, 12, 0, 0);

// Format the custom date
console.log(`Custom Date: ${customDate.format('Full day, M D, Y')}`);

// Calculate the time difference
console.log(`Time Difference: ${customDate.when()}`);

License

This project is licensed under the MIT License. See the LICENSE file for details.


ansi-escapesansi-regexansi-stylesanymatchargparsebabel-jestbabel-plugin-istanbulbabel-plugin-jest-hoistbabel-preset-current-node-syntaxbabel-preset-jestbalanced-matchbluebirdbrace-expansionbracesbrowserslistbserbuffer-fromcallsitescamelcasecaniuse-litecatharsischalkchar-regexci-infocjs-module-lexercliuicocollect-v8-coveragecolor-convertcolor-nameconcat-mapconvert-source-mapcross-spawndebugdedentdeepmergedetect-newlinediff-sequenceselectron-to-chromiumemitteryemoji-regexentitieserror-exescaladeescape-string-regexpesprimaexecaexitexpectfast-json-stable-stringifyfb-watchmanfill-rangefind-upfs.realpathfseventsfunction-bindgensyncget-caller-fileget-package-typeget-streamglobglobalsgraceful-fshashas-flaghtml-escaperhuman-signalsimport-localimurmurhashinflightinheritsis-arrayishis-core-moduleis-fullwidth-code-pointis-generator-fnis-numberis-streamisexeistanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-reportistanbul-lib-source-mapsistanbul-reportsjest-changed-filesjest-circusjest-clijest-configjest-diffjest-docblockjest-eachjest-environment-nodejest-get-typejest-haste-mapjest-leak-detectorjest-matcher-utilsjest-message-utiljest-mockjest-pnp-resolverjest-regex-utiljest-resolvejest-resolve-dependenciesjest-runnerjest-runtimejest-snapshotjest-utiljest-validatejest-watcherjest-workerjs-tokensjs-yamljs2xmlparserjsescjson-parse-even-better-errorsjson5klawkleurlevenlines-and-columnslinkify-itlocate-pathlodashlru-cachemake-dirmakeerrormarkdown-itmarkdown-it-anchormarkedmdurlmerge-streammicromatchmimic-fnminimatchmkdirpmsnatural-comparenode-int64node-releasesnormalize-pathnpmnpm-run-pathonceonetimep-limitp-locatep-tryparse-jsonpath-existspath-is-absolutepath-keypath-parsepicocolorspicomatchpiratespkg-dirpretty-formatpromptspure-randreact-isrequire-directoryrequizzleresolveresolve-cwdresolve-fromresolve.exportssemvershebang-commandshebang-regexsignal-exitsisteransislashsource-mapsource-map-supportsprintf-jsstack-utilsstring-lengthstring-widthstrip-ansistrip-bomstrip-final-newlinestrip-json-commentssupports-colorsupports-preserve-symlinks-flagtest-excludetmplto-fast-propertiesto-regex-rangetype-detecttype-festuc.microunderscoreupdate-browserslist-dbv8-to-istanbulwalkerwhichwrap-ansiwrappywrite-file-atomicxmlcreatey18nyallistyargsyargs-parseryocto-queue
1.1.1

8 months ago

1.0.1

8 months ago