https://github.com/sleavely/next-monthly
Determine the next monthly occurence of a JS date, falling back on the last day of the month
https://github.com/sleavely/next-monthly
dates javascript monthly nodejs recurring-payments
Last synced: 7 months ago
JSON representation
Determine the next monthly occurence of a JS date, falling back on the last day of the month
- Host: GitHub
- URL: https://github.com/sleavely/next-monthly
- Owner: Sleavely
- License: mit
- Created: 2022-08-23T14:59:17.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-09T21:35:33.000Z (over 2 years ago)
- Last Synced: 2025-01-12T16:12:28.225Z (9 months ago)
- Topics: dates, javascript, monthly, nodejs, recurring-payments
- Language: JavaScript
- Homepage:
- Size: 313 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# next-monthly
Determine the next monthly occurence, falling back on the last day of the month.
[  ](https://npmjs.org/package/next-monthly "View package")
[  ](https://github.com/Sleavely/next-monthly/actions/workflows/node.js.yml "View workflow")## Installation
```sh
npm i next-monthly
```## Usage
```js
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](https://www.npmjs.com/package/rrule) - Library for working with recurrence rules for calendar dates according to RFC 5545.