Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smhg/full-week
Calculate the start of the nth full week of a year or month.
https://github.com/smhg/full-week
Last synced: about 2 months ago
JSON representation
Calculate the start of the nth full week of a year or month.
- Host: GitHub
- URL: https://github.com/smhg/full-week
- Owner: smhg
- License: mit
- Created: 2018-11-15T13:27:58.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-22T09:08:57.000Z (over 3 years ago)
- Last Synced: 2024-10-11T23:11:37.669Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 532 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# full-week [![ci](https://github.com/smhg/full-week/actions/workflows/ci.yml/badge.svg)](https://github.com/smhg/full-week/actions/workflows/ci.yml)
Calculate the start of the *n*th full week of a year or month.## API
### fullWeek(index, year)
Calculate the start of the nth week of a year
### fullWeek(index, year, month = 0)
Calculate the start of the nth week of a month
### fullWeek(index, year, month = 0, startOfWeek = 1)
Calculate the start of the nth week of a month defining on what day weeks start
> **Note:** `month` and `startOfWeek` parameters use JavaScript's indexing approach (January = 0, first day of the week = 0)
## Usage
```javascript
import fullWeek from 'full-week';// start of first full week of 2021
fullWeek(1, 2021); // 2021-01-04T00:00:00// start of 3rd full week of November 2018
fullWeek(3, 2018, 10); // 2018-11-19T00:00:00const firstFullWeek = (year, month) => fullWeek(1, year, month);
// start of first full week of November 2018
firstFullWeek(2018, 10); // 2018-11-05T00:00:00
// start of first full week of 2019
firstFullWeek(2019); // 2019-01-07T00:00:00// start of last full week of April 2019
fullWeek(-1, 2019, 4); // 2019-04-22T00:00:00
```