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

datility

v0.1.3

Published

Missing javascript Date object utilities

Readme

Installation

npm i datility --save
yarn add datility
pnpm add datility

Usage

All methods are accessible via Date object. With this line all methods, properties and so on added to the Date object.

import "datility";

console.log(new Date(2022, 5, 3).addDays(1)); // => Sat Jun 04 2022 00:00:00 GMT+0300 (GMT+03:00)

Also, can import methods from the specified category:

import "datility";

manipulate category

import "datility/manipulate";
import "datility/manipulate/add";
import "datility/manipulate/subtract";
import "datility/manipulate/reference";

comparison category

import "datility/comparison";

working-days category

import "datility/working-days";

Methods

Manipulate Category

Add Methods

addDays(days: number): Date

Add day(s) to the Date.

new Date(2022, 6, 9).addDays(3); // => Tue Jul 12 2022 00:00:00 GMT+0300 (GMT+03:00)

addWorkingDays(days: number): Date

Add working day(s) to the Date.

new Date(2022, 6, 9).addWorkingDays(3); // => Wed Jul 13 2022 00:00:00 GMT+0300 (GMT+03:00)

addWeeks(months: number): Date

Add week(s) to the Date.

new Date(2022, 6, 9).addWeeks(3); // => Sat Jul 30 2022 00:00:00 GMT+0300 (GMT+03:00)

addMonths(months: number): Date

Add month(s) to the Date.

new Date(2022, 6, 9).addMonths(3); // => Sun Oct 09 2022 00:00:00 GMT+0300 (GMT+03:00)

addYears(years: number): Date

Add year(s) to the Date.

new Date(2022, 6, 9).addYears(3); // => Wed Jul 09 2025 00:00:00 GMT+0300 (GMT+03:00)

Subtract Methods

subtractDays(days: number): Date

Subtract day(s) from the Date.

new Date(2022, 6, 9).subtractDays(3); // => Wed Jul 06 2022 00:00:00 GMT+0300 (GMT+03:00)

subtractWorkingDays(days: number): Date

Subtract working day(s) from the Date.

new Date(2022, 6, 8).subtractWorkingDays(4); // => Mon Jun 27 2022 00:00:00 GMT+0300 (GMT+03:00)

subtractWeeks(months: number): Date

Subtract week(s) from the Date.

new Date(2022, 6, 9).subtractWeeks(3); // => Sat Jun 18 2022 00:00:00 GMT+0300 (GMT+03:00)

subtractMonths(months: number): Date

Subtract month(s) from the Date.

new Date(2022, 6, 9).subtractMonths(3); // => Sat Apr 09 2022 00:00:00 GMT+0300 (GMT+03:00)

subtractYears(years: number): Date

Subtract year(s) from the Date.

new Date(2022, 6, 9).subtractYears(3); // => Tue Jul 09 2019 00:00:00 GMT+0300 (GMT+03:00)

Reference Methods

clone(): Date

Clone the Date by value.

const date = new Date(2022, 5, 9);
console.log(date, date.clone().addDays(10)); // => Sat Jun 09 2022 00:00:00 GMT+0300 (GMT+03:00), Sat Jun 19 2022 00:00:00 GMT+0300 (GMT+03:00)

Comparison Category

isBefore(given: Date): boolean

Check if the Date is before the given Date.

new Date(2022, 5, 9).isBefore(new Date(2022, 5, 10)); // => true
new Date(2022, 5, 9).isBefore(new Date(2022, 5, 9)); // => false
new Date(2022, 5, 9).isBefore(new Date(2022, 5, 8)); // => false

isSame(given: Date): boolean

Check if the Date is the same as the given Date.

new Date(2022, 5, 9).isSame(new Date(2022, 5, 9)); // => true
new Date(2022, 5, 9).isSame(new Date(2022, 5, 10)); // => false

isAfter(given: Date): boolean

Check if the Date is after the given Date.

new Date(2022, 5, 9).isAfter(new Date(2022, 5, 8)); // => true
new Date(2022, 5, 9).isAfter(new Date(2022, 5, 9)); // => false
new Date(2022, 5, 9).isAfter(new Date(2022, 5, 10)); // => false

isSameOrBefore(given: Date): boolean

Check if the Date is the same or before the given Date.

new Date(2022, 5, 9).isSameOrBefore(new Date(2022, 5, 10)); // => true
new Date(2022, 5, 9).isSameOrBefore(new Date(2022, 5, 10)); // => true
new Date(2022, 5, 9).isSameOrBefore(new Date(2022, 5, 8)); // => false

isSameOrAfter(given: Date): boolean

Check if the Date is the same or after the given Date.

new Date(2022, 5, 9).isSameOrAfter(new Date(2022, 5, 8)); // => true
new Date(2022, 5, 9).isSameOrAfter(new Date(2022, 5, 9)); // => true
new Date(2022, 5, 9).isSameOrAfter(new Date(2022, 5, 10)); // => false

isBetween(start: Date, end: Date): boolean

Check if the Date is between the given start and end Date.

new Date(2022, 5, 9).isBetween(new Date(2022, 5, 8), new Date(2022, 5, 10)); // => true
new Date(2022, 5, 9).isBetween(new Date(2022, 5, 8), new Date(2022, 5, 9)); // => false
new Date(2022, 5, 9).isBetween(new Date(2022, 5, 8), new Date(2022, 5, 8)); // => false

isPast(given: Date): boolean

Check if the Date is past the given Date.

new Date(2022, 5, 9).isPast(new Date(2022, 5, 10)); // => false
new Date(2022, 5, 9).isPast(new Date(2022, 5, 9)); // => false
new Date(2022, 5, 9).isPast(new Date(2022, 5, 8)); // => true

isFuture(given: Date): boolean

Check if the Date is future the given Date.

new Date(2022, 5, 9).isFuture(new Date(2022, 5, 10)); // => true
new Date(2022, 5, 9).isFuture(new Date(2022, 5, 9)); // => false
new Date(2022, 5, 9).isFuture(new Date(2022, 5, 8)); // => false

isDay(dayName: DayName): boolean

Check if the Date is the given dayName.

new Date(2022, 5, 5).isDay("Sunday"); // => true
new Date(2022, 5, 6).isDay("monday"); // => true
new Date(2022, 5, 7).isDay("Tue"); // => true
new Date(2022, 5, 8).isDay("wed"); // => true
new Date(2022, 5, 9).isDay("Saturday"); // => false

Working Days Category

isWorkingDay(): boolean

Check if the Date is a working day.

new Date(2022, 5, 5).isWorkingDay(); // => false
new Date(2022, 5, 6).isWorkingDay(); // => false
new Date(2022, 5, 8).isWorkingDay(); // => true

isWeekend(): boolean

Check if the Date is a weekend day.

new Date(2022, 5, 5).isWeekend(); // => true
new Date(2022, 5, 6).isWeekend(); // => true
new Date(2022, 5, 8).isWeekend(); // => false

addWorkingDays(days: number): Date

Add days working days to the Date.

new Date(2022, 5, 3).addWorkingDays(1); // => Sat Jun 06 2022 00:00:00 GMT+0300 (GMT+03:00)
new Date(2022, 5, 3).addWorkingDays(2); // => Sun Jun 07 2022 00:00:00 GMT+0300 (GMT+03:00)
new Date(2022, 5, 3).addWorkingDays(3); // => Mon Jun 08 2022 00:00:00 GMT+0300 (GMT+03:00)

subtractWorkingDays(days: number): Date

Subtract days working days to the Date.

new Date(2022, 5, 6).subtractWorkingDays(1); // => Fri Jun 03 2022 00:00:00 GMT+0300 (GMT+03:00)
new Date(2022, 5, 6).subtractWorkingDays(2); // => Thu Jun 02 2022 00:00:00 GMT+0300 (GMT+03:00)
new Date(2022, 5, 6).subtractWorkingDays(3); // => Wed Jun 01 2022 00:00:00 GMT+0300 (GMT+03:00)

License

MIT License