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

@giannisclipper/date

v1.0.0

Published

A set of functions to handle date values in various shapes

Readme

A set of functions to handle date values in various shapes

(version 1.0.0)

  • Functions are grouped into:

    • set*(), to create various value shapes expressing a date:

      • setDateObj( value ), a simple object with integer values ({ year:, month:, day: })

      • setDateArray( value ), an array of integers ([ yaer, month, day ])

      • setDateStr( value ), a string in form of 'YYYYMMDD' (where YYYY is for year, MM for month, DD for day)

      • setDateRepr( value, pattern ) a representation string in form of 'DD/MM/YYYY' (by default but also customizable to other patterns)

      • setDateDate( value ) an instance of JS Date class

    • get*(), to evaluate and retrieve the date values from the above shapes:

      • getDateObj( value ), date values from an object ({ year:, month:, day: })

      • getDateArray( value ), date values from an array of integers ([ yaer, month, day ])

      • getDateStr( value ), date values from a string in form of 'YYYYMMDD'

      • getDateRepr( value, pattern ), date values from a representation string like 'DD/MM/YYYY'

      • getDateDate( value ), date values from an instance of JS Date class

    • op*(), to compare two date values:

      • opEqualTo( date1, date2 ), the one date should be equal to the other

      • opNotEqualTo( date1, date2 ), the one date should not be equal to the other

      • opGreaterThan( date1, date2 ), the first date should be greater than the second

      • opGreaterThanEqualTo( date1, date2 ), the first date should be greater than or equal to the second

      • opLessThan( date1, date2 ), the first date should be less than the second

      • opLessThanEqualTo( date1, date2 ), the first date should be less than or equal to the second

    • calc*(), to calculate new date or related values:

      • calcDayOfWeek( date ), the position of a date in the days sequence of the week (from 1 to 7, monday to sunday)

      • calcDayOfYear( date ), the position of a date in the days sequence of the year (from 1 to 365/366)

      • calcDateByDayOfYear( day, year ), the date according to a day in the sequence of a year (from 1 to 365/366)

      • calcDateByDaysAddition( from, days ), the date according to a starting date and a positive or negative number of days to be added

      • calcWeeksOfRange( from, till ), the weeks according to a range of days that are placed within

    • count*(), to count date related values

      • countDaysOfMonth( month, year ), the number of days of a month

      • countDaysOfYear( year ), the number of days of a year

      • countDaysOfRange( from, till ), the number of days of a date range including the starting and ending limits

    • is*(), to validate date related values:

      • isYear( value ), if a value is an integer expressing a year (by default from 1900 to 2099 but also customizable to other values)

      • isLeapYear( value ), if a value is an integer expressing a leap year

      • isMonth( month, year ), if a value is an integer expressing a month (from 1 to 12)

      • isDate( year, month, day ), if a series of values expressing a date

    • config.set*(), to customize general parameters:

      • config.setYearRange( from, till ), the range of valid years (by default from 1900 to 2099)

      • config.setReprPattern( pattern ), the pattern for the date representation (by default DD/MM/YYYY)

    • config.get*(), to retrieve general parameters:

      • config.getYearRange(), the range of valid years

      • config.getReprPattern(), the pattern for the date representation

Repository here

Documentation here