Socket
Socket
Sign inDemoInstall

@gramsay7/date-lib

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @gramsay7/date-lib

The `D` class is a utility class for working with dates in JavaScript. It provides several convenient methods and properties for getting and formatting dates.


Version published
Maintainers
1
Created

Readme

Source

D - A Date Utility Class

The D class is a utility class for working with dates in JavaScript. It provides several convenient methods and properties for getting and formatting dates.

Installation

npm install @gramsay7/date-lib

Usage

First, import the D class from the package:

import D from '@gramsay7/date-lib';

Then, you can create a new D object:

const d = new D(2017, 8, 2, 3, 4, 5); // September 2, 2017 03:04:05

You can use the getters to get various parts of the date:

console.log(d.year); // 2017
console.log(d.yr); // 17
console.log(d.month); // September
console.log(d.mon); // Sep
console.log(d.day); // Saturday
console.log(d.dy); // Sat
console.log(d.date); // 2
console.log(d.hours); // 3
console.log(d.mins); // 4
console.log(d.secs); // 5
console.log(d.ordinal); // 2nd

You can use the format method to format the date:

console.log(d.format('Y-M-D h:i:s')); // 2017-September-02 03:04:05

You can use the when method to get a human-readable description of when the date will occur:

console.log(d.when()); // 4 years ago (assuming the current date is in 2021)

Tests

To run the tests for the D class, use the following command:

npm test

FAQs

Last updated on 02 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc