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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@keerthana_lagadapati/date-utilities

v1.0.1

Published

The Date Utilities Module provides a collection of reusable functions to simplify working with dates in JavaScript.

Readme

Date Utilities Module

The Date Utilities Module provides a collection of reusable functions to simplify working with dates in JavaScript. It is lightweight, consistent, and highly useful for a wide range of applications, including MERN stack projects.


Features

  1. Date Formatting: Convert date objects into specific string formats (e.g., DD-MM-YYYY).
  2. Add/Subtract Days: Easily manipulate date objects by adding or subtracting days.
  3. Leap Year Check: Determine if a given year is a leap year.
  4. Weekday Names: Retrieve the weekday name for any date.
  5. Day Difference Calculation: Calculate the difference in days between two dates.
  6. Weekend Check: Check if a given date falls on a weekend.

Installation

To use the Date Utilities Module in your project, install it via npm:

npm install @keerthana_lagadapati/date-utilities

Usage

Importing the Module

import DateUtils from '@keerthana_lagadapati/date-utilities';

Available Functions

1. formatDate(date, format)

Formats a date object into a specified format.

Parameters:

  • date: The date object to format.
  • format: The desired string format (default: "DD-MM-YYYY").

Example:

const today = new Date();
console.log(DateUtils.formatDate(today, "DD/MM/YYYY")); // Output: e.g., 28/01/2025

2. addDays(date, days)

Adds a specified number of days to a date object.

Parameters:

  • date: The base date object.
  • days: The number of days to add.

Example:

const today = new Date();
console.log(DateUtils.addDays(today, 5)); // Output: Date 5 days from today

3. subtractDays(date, days)

Subtracts a specified number of days from a date object.

Parameters:

  • date: The base date object.
  • days: The number of days to subtract.

Example:

const today = new Date();
console.log(DateUtils.subtractDays(today, 5)); // Output: Date 5 days ago

4. isLeapYear(year)

Checks if a given year is a leap year.

Parameters:

  • year: The year to check.

Example:

console.log(DateUtils.isLeapYear(2024)); // Output: true

5. getWeekday(date)

Returns the weekday name for a given date.

Parameters:

  • date: The date object to evaluate.

Example:

const today = new Date();
console.log(DateUtils.getWeekday(today)); // Output: e.g., "Monday"

6. daysBetween(date1, date2)

Calculates the number of days between two dates.

Parameters:

  • date1: The first date.
  • date2: The second date.

Example:

const date1 = new Date('2025-01-01');
const date2 = new Date('2025-01-10');
console.log(DateUtils.daysBetween(date1, date2)); // Output: 9

7. isWeekend(date)

Checks if a date falls on a weekend.

Parameters:

  • date: The date object to evaluate.

Example:

const today = new Date();
console.log(DateUtils.isWeekend(today)); // Output: true or false

Use Cases

1. Task or Event Management

  • Use Case: For a task management system or event scheduler, addDays and formatDate can help set deadlines or display events in a human-readable format.
  • Example: Automatically calculate and display task due dates.

2. User-Friendly Timestamps

  • Use Case: Display user activity logs (e.g., "Last login: 12-Jan-2025").
  • Example: Use formatDate to show user activity in readable formats in the front-end.

3. Reminder System

  • Use Case: Schedule reminders for users (e.g., reminders for upcoming appointments or renewals).
  • Example: Use addDays to calculate future reminders and daysBetween to determine how soon reminders should be sent.

4. Analytics Dashboard

  • Use Case: Display trends over time (e.g., daily active users or revenue growth).
  • Example: Use daysBetween to calculate date ranges for analytics queries.

5. Content Expiry Handling

  • Use Case: Automatically expire content after a certain period (e.g., temporary posts or promotional offers).
  • Example: Use subtractDays to calculate content expiry dates in both front-end and back-end.

6. Localization of Weekdays

  • Use Case: Display localized weekday names in a calendar component.
  • Example: Use getWeekday for a user-friendly calendar in the front-end.

7. Leap Year Logic

  • Use Case: Handle leap-year scenarios for billing cycles or subscription periods.
  • Example: Use isLeapYear to accurately calculate yearly plans.