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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nexttime

v0.1.1

Published

Simple tool set to calculate next event occurring date.

Downloads

2

Readme

NextTime

Simple tool set to calculate next event occurring date.

Installation

Use NPM to install using;

npm install nexttime --save

Getting Started

NextTime module contains an API to predict next event occurring date or dates. Lets assume that current date is Tue Dec 01 2015 00:00:00 GMT+0530 (IST). Then following method calls will calculate required events as below;

// Create a NextTime instance
let nextTime = require('nexttime').NextTime;

nextTime.nextDate();
// Wed Dec 02 2015 00:00:00 GMT+0530 (IST)
nextTime.nextDate(new Date(2015, 11, 1));
// Wed Dec 02 2015 00:00:00 GMT+0530 (IST)

nextTime.nextDate(new Date(2015,11,1), new Date(2015,11,4));
// ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Wed Dec 02 2015 00:00:00 GMT+0530 (IST)', 'Thu Dec 03 2015 00:00:00 GMT+0530 (IST)']
nextTime.nextDate(new Date(2015,11,4));
// ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Wed Dec 02 2015 00:00:00 GMT+0530 (IST)', 'Thu Dec 03 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextWeek();
// Tue Dec 08 2015 00:00:00 GMT+0530 (IST)
nextTime.nextWeek(new Date(2015, 11, 1));
// Tue Dec 08 2015 00:00:00 GMT+0530 (IST)

nextTime.nextWeeks(new Date(2015,11,1), new Date(2015,11,10));
// ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Tue Dec 08 2015 00:00:00 GMT+0530 (IST)']
nextTime.nextWeeks(new Date(2015,11,11));
// ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Tue Dec 08 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextMonth();
// Fri Jan 01 2016 00:00:00 GMT+0530 (IST)
nextTime.nextMonth(new Date(2015, 11, 1));
// Fri Jan 01 2016 00:00:00 GMT+0530 (IST)
nextTime.nextMonth(new Date(2016,1,29), 31);
// 'Thu Mar 31 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextMonths(new Date(2015,11,31), new Date(2016,2,24));
// ['Thu Dec 31 2015 00:00:00 GMT+0530 (IST)', 'Sun Jan 31 2015 00:00:00 GMT+0530 (IST)', 'Mon Feb 29 2015 00:00:00 GMT+0530 (IST)']
nextTime.nextMonths(new Date(2016,2,24));
// ['Thu Dec 31 2015 00:00:00 GMT+0530 (IST)', 'Sun Jan 31 2015 00:00:00 GMT+0530 (IST)', 'Mon Feb 29 2015 00:00:00 GMT+0530 (IST)']

API

  1. nextDate([date])
  2. nextDates([startDate], endDate)
  3. nextWeek([date])
  4. nextWeeks([startDate], endDate)
  5. nextMonth([date] [,upto])
  6. nextMonths([startDate], endDate)

1. nextDate([date])

Get next date after a given date

Parameters
  • date : {Integer/Date/Date String} A valid date format

(optional) Default new Date()

Return
  • {Date} Next Date instance
USAGE:

If current date is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', then following method return 'Wed Dec 02 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextDate();

If feed with a date 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', then following method return 'Wed Dec 02 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextDate(new Date(2015,11,1));

2. nextDates([startDate], endDate)

Get next dates between given startDate and endDate period

Parameters
  • startDate : {Integer/Date/Date String} A valid date format

(optional) Default new Date()

  • endDate : {Integer/Date/Date String} A valid date format

(required) If endDate isn't provided, take startDate as endDate

Return
  • {Array of Date} Next Dates instance
USAGE:

If startDate is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)' and endDate is 'Fri Dec 04 2015 00:00:00 GMT+0530 (IST)', then following method return ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Wed Dec 02 2015 00:00:00 GMT+0530 (IST)', 'Thu Dec 03 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextDates(new Date(2015,11,1), new Date(2015,11,4));

If current time is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)' and call method with 'Fri Dec 04 2015 00:00:00 GMT+0530 (IST)' will return ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Wed Dec 02 2015 00:00:00 GMT+0530 (IST)', 'Thu Dec 03 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextDates(new Date(2015,11,4));

3. nextWeek([date])

Get date of next week for a given date

Parameters
  • date : {Integer/Date/Date String} A valid date format

(optional) Default new Date()

Return
  • {Date} Next week Date instance
USAGE:

If current date is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', then following method return 'Tue Dec 08 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextWeek();

If feed with a date 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', then following method return 'Tue Dec 08 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextWeek(new Date(2015,11,1));

4. nextWeeks([startDate], endDate)

Get dates of next weeks between given startDate and endDate period

Parameters
  • startDate : {Integer/Date/Date String} A valid date format

(optional) Default new Date()

  • endDate : {Integer/Date/Date String} A valid date format

(required) If endDate isn't provided, take startDate as endDate

Return
  • {Array of Date} Next weeks' Date objects
USAGE:

If startDate is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)' and endDate is 'Fri Dec 11 2015 00:00:00 GMT+0530 (IST)', then following method return ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Tue Dec 08 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextWeeks(new Date(2015,11,1), new Date(2015,11,10));

If current time is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)' and call method with 'Fri Dec 11 2015 00:00:00 GMT+0530 (IST)' will return ['Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', 'Tue Dec 08 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextWeeks(new Date(2015,11,11));

5. nextMonth([date] [,upto])

Get date of next month for a given date NOTE: When end of month provided, it'll return possible end of next month

Parameters
  • date : {Integer/Date/Date String} A valid date format

(optional) Default new Date()

  • upto : {Integer} Most value end of month can change

(optional) Default set to date of date parameter

Return
  • {Date} Next month Date instance
USAGE:

If current date is 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', then following method return 'Fri Jan 01 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextMonth();

If feed with a date 'Tue Dec 01 2015 00:00:00 GMT+0530 (IST)', then following method return 'Fri Jan 01 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextMonth(new Date(2015,11,1));

NOTE:

If upto provided 'Mon Feb 29 2016 00:00:00 GMT+0530 (IST)', then return 'Thu Mar 31 2015 00:00:00 GMT+0530 (IST)'

nextTime.nextMonth(new Date(2016,1,29), 31);

6. nextMonths([startDate], endDate)

Get dates of next months between given startDate and endDate period

Parameters
  • startDate : {Integer/Date/Date String} A valid date format

(optional) Default new Date()

  • endDate : {Integer/Date/Date String} A valid date format

(required) If endDate isn't provided, take startDate as endDate

Return
  • {Array of Date} Next months' Date objects
USAGE:

If startDate is 'Thu Dec 31 2015 00:00:00 GMT+0530 (IST)' and endDate is 'Thu Mar 24 2016 00:00:00 GMT+0530 (IST)', then following method return ['Thu Dec 31 2015 00:00:00 GMT+0530 (IST)', 'Sun Jan 31 2015 00:00:00 GMT+0530 (IST)', 'Mon Feb 29 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextMonths(new Date(2015,11,31), new Date(2016,2,24));

If current time is 'Thu Dec 31 2015 00:00:00 GMT+0530 (IST)' and call method with 'Thu Mar 24 2016 00:00:00 GMT+0530 (IST)' will return ['Thu Dec 31 2015 00:00:00 GMT+0530 (IST)', 'Sun Jan 31 2015 00:00:00 GMT+0530 (IST)', 'Mon Feb 29 2015 00:00:00 GMT+0530 (IST)']

nextTime.nextMonths(new Date(2016,2,24));

Testing

  1. Install dependencies with npm install
  2. Run test cases
  • npm run test (just tests)
  • npm run test-debug (test with more debug logs)

License

This Software is licensed under MIT License

Copyright (c) 2015 Gihan Karunarathne [email protected]