next-monthly
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

next-monthly

Determine the next monthly occurence, falling back on the last day of the month.

npm version CI status

Installation

npm i next-monthly

Usage

const nextMonthly = require('next-monthly')

// Jan 31, Feb 28 or 29, etc.
const lastDayOfThisMonth = nextMonthly()

// If you want to charge users who signed up on the 30th (but sometimes on Feb 28, etc.)
const nextBillingDate = nextMonthly({
  from: '1990-01-07T01:29:03.999Z',

  // Defaults to Date.now(). Only used here for demo purpose:
  now:  '2022-08-23T12:29:08.551Z',
})
// Date: 2022-09-07T01:29:03.999Z

Options

Property Description
from The basis for the monthly occurrance. Defaults to 0000-01-31T00:00:00.000Z for a classic last-day-of-month experience.
now The point in time from which to look for the next occurance. Defaults to Date.now().

See also

  • rrule - Library for working with recurrence rules for calendar dates according to RFC 5545.

Package Sidebar

Install

npm i next-monthly

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

7.98 kB

Total Files

12

Last publish

Collaborators

  • sleavely