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

superdate-js

v1.1.7

Published

A Node package that extends date builtin functions

Readme

Superdate.js

Welcome to the docs of Superdate.js. A Node.js library that extends the main function of the Date javascript class.

Solution

Some scenarios that could be achieved with Superdate.js:

  • Every method that can be called in javascript builtin Date() class can also be called in Superdate.js.
  • Optionally, developer can set workdays in order to perform further comparisons.
  • It's possible to perform date comparisons.
  • Different than javascript builtin Date() class, here you won't need to reinstance an object in order to compare dates. You could use the method setComparisonDate() and the retrieve it with getComparisonDate().
  • This and much more is about to come.

Object Construction

You can instance the object calling superdate class. Example:

const superdate = require('superdate-js');
const sd = new superdate();

You can insert an object with following properties in the class construction:

  • mainDate - Defines the date to be considered (It has the same usage of the javascript Date class). If you omit it, the date considered will be current.

     const sd = new superdate({
         mainDate: '2023-06-02' // format should be the same as object Date from javascript
     });
  • workdays - Optionally, the developer can set the workdays to the date chosen. The value needs to be an array with the day code. (0 = Sunday, 1 = Monday, etc.. , 6 = Saturday).

     const sd = new superdate({
         mainDate: '2023-06-02',
         workdays: [1,2,3,4,5] // That from monday to saturday
     });

Methods

superdate objects inherit all the methods from Date javascript class. Plus, it has some extended methods that help the developer in implementations

  • setComparisonDate() - It's a function to escape from main date template and set a new one for comparisons.

    • Parameter - It can be the same parameters of Date() constructor.
    • Returns - true if succeeded.
     const sd = new superdate({
         mainDate: '2023-06-02' // format should be the same as object Date from javascript
     });
     sd.setComparisonDate('2023-06-06'); // Defines a different date to perform comparisons.
  • getComparisonDate() - It's used to retrieve the date object seted in the function setComparisonDate() to perform comparisons.

    • Parameter - none.
    • Returns - A Date object as setted in function setComparisonDate().
     const sd = new superdate({
         mainDate: '2023-06-02', // format should be the same as object Date from javascript
         workdays: [1,2,3,4,5] // Monday to Friday 
     });
     sd.setComparisonDate('2023-06-06');
     sd.isWorkDay(sd.getComparisonDate()); // Return true since 06/06/2023 is Tuesday.
  • getWeekDay() - It's a function to get the day of the week based on the date defined in the class construction.

    • Parameter - none.
    • Returns - The name of the day of the week (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday or Saturday).
     const sd = new superdate({
         workdays: [3,4,5] // Wednesday to Friday 
     });
     console.log(sd.getWeekDay()); // Returns a string with the weekday name. e.g. Friday
  • getFirstDay() - Function that retrieves the first day of month based on user input.

    • Parameter - Any date as the Date() call format.
    • Default - If no parameter is setted, the date considered is the one in the construction of the class.
    • Returns - A date Object.
     const sd = new superdate({
         workdays: [3,4,5] // Wednesday to Friday 
     });
     sd.setComparisonDate('2029-12-20');
     console.log(sd.getFirstDay(sd.getComparisonDate())); // Returns the first day of december/2029 - 2029-12-01
  • getLastDay() - Function that retrieves the last day of month based on user input.

    • Parameter - Any date as the Date() call format.
    • Returns - A date Object.
     const sd = new superdate({
         workdays: [3,4,5] // Wednesday to Friday 
     });
     sd.setComparisonDate('2029-12-20');
     console.log(sd.getLastDay(sd.getComparisonDate())); // Returns the last day of december/2029 - 2029-12-31
  • getWorkDays() - It's a function to get all the workdays based on the date defined in the class construction.

    • Parameter - none.
    • Returns - An array with the days name e.g [Monday, Tuesday, Wednesday, Thursday, Friday].
     const sd = new superdate({
         workdays: [3,4,5] // Wednesday to Friday 
     });
     console.log(sd.getWorkDays()); // Returns array ['Wednesday','Thursday','Friday'];
  • isWorkDay() - It's a function to check whether a date is a work day, based on the atribute workdays defined in the class construction.

    • Parameter - none.
    • Returns - true if it's a work day and false if it's not.
     const sd = new superdate({
         workdays: [3,4,5] // Wednesday to Friday 
     });
     sd.setComparisonDate('2029-12-20');
     console.log(sd.isWorkDay(sd.getComparisonDate())); // Returns true, since it's a Wednesday

Next improvements

We will continuously add more functions to the package, but one of our main goals is switching it to Typescript. So, if you like to collaborate, please check our pages:

  • Github Repository: https://github.com/nholipau/superdate

  • NPM Package: https://www.npmjs.com/package/superdate-js