npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sharshar/date-lib

v1.1.1

Published

The `D` class is a simple date manipulation class designed to make working with dates and times in JavaScript easier. It provides a set of methods and properties to retrieve various date-related information and format dates according to different masks.

Downloads

1

Readme

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.