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

dates-ranger

v0.1.1

Published

dates util facilitates operations on two dates

Downloads

4

Readme

dates-ranger

Dates-ranger helps you find date intervals and calculate duration much easier than ever. This library is light-weighted and dependency free, and it is purely developed in Typescript.

Table of Contents

Install

This node module is ditributed to npm with bi-weekly release in the year of 2021

You can install it by running:

npm install -g dates-ranger

Usage

Background

In various use cases, people would like to query data in a specific period, such as "Week to Date", "Last Month" or "Recent Three Days", It is hard to find them as TODAY moves forward. And in many calendar apps, people are interested in the duration between given dates. All is made easy with this library.

Interval API

Interval API introduces DateInterval(standAt?:string) Object for methods returning Array([startDate:string, endDate:string]). These are:

const interval = new DateInterval('12/12/2020'); //intialize an object with standAt='12/12/2020', default is TODAY
interval.getIntervalForYesterday(); //[ '12/11/2020', '12/11/2020' ]
interval.getIntervalForWeekToDate((newCycleDay = 'Mon')); //[ '12/7/2020', '12/12/2020' ]
interval.getIntervalForWeekToDate((newCycleDay = 'Sun')); //[ '12/6/2020', '12/12/2020' ]
interval.getIntervalForWeekToDate((newCycleDay = 'Sat')); //[ '12/12/2020', '12/12/2020' ]
interval.getIntervalForPreviousWeek(); //[ '11/30/2020', '12/6/2020' ]
interval.getIntervalForMonthToDate(); //[ '12/1/2020', '12/12/2020' ]
interval.getIntervalForPreviousMonth(); //[ '11/1/2020', '11/30/2020' ]
interval.getIntervalForYearToDate(); //[ '1/1/2020', '12/12/2020' ]
interval.getIntervalForPreviousYear(); //[ '1/1/2019', '12/31/2019' ]
interval.getIntervalForRecentNDays((n = 5)); //[ '12/8/2020', '12/12/2020' ]
interval.getIntervalForRecentNDays((n = 5), (inclusive = true)); //[ '12/7/2020', '12/12/2020' ]

Duration API

Duration API introduces Duration(standAt?:string) Object for methods returning counts:number. These are:

const duration = new Duration(); //by default, Today is where we stand at
duration.btwTodayAndDestination(new Date()); //return 0
duration = new Duration('12/12/2020'); //intialize an object with standAt='12/12/2020', so you see this date as TODAY
duration.btwTodayAndDestination('12/13/2020'); //return 1
duration.btwTodayAndDestination('12/7/2020'); //return -5

//static method
Duration.btwDates('12/13/2020', '12/10/2020'); //return -3
Duration.btwDates(new Date('12/13/2020'), new Date('11/30/2020')); //return -13
Duration.btwDates(...new DateInterval().getIntervalForPreviousYear()); //return 364

More usage info, please consult documentation and unit test.

TODO

| Task | Expected Delivery | | -------------------------------------------------------------- | ----------------- | | TimeInterval to provide utilities for time interval operations | 12/31/2020 | | Date Formater to let users easily format the output dates | 1/15/2021 |

Maintainer

@cstechfoodie

Contributing

Please contribute! Look at the issues.

License

MIT © 2020 Shunyu Wang