Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fsubal/dayjs-range-support
Add dayjs.range() to yield each days between some period
https://github.com/fsubal/dayjs-range-support
Last synced: about 1 month ago
JSON representation
Add dayjs.range() to yield each days between some period
- Host: GitHub
- URL: https://github.com/fsubal/dayjs-range-support
- Owner: fsubal
- License: mit
- Created: 2020-12-01T12:56:16.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-05T04:29:16.000Z (about 4 years ago)
- Last Synced: 2025-01-03T01:59:16.746Z (about 2 months ago)
- Language: TypeScript
- Size: 107 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dayjs-range-support
Add `dayjs.range()` to yield each day between some period
```
npm install -S @fsubal/dayjs-range-support
``````
yarn add @fsubal/dayjs-range-support
```## Usage
`dayjs.range()` returns a **generator** (not `dayjs.Dayjs[]`)!
```ts
Array.from(dayjs.range('2020-12-01', '2020-12-31'))
[...dayjs.range('2020-12-01', '2020-12-31')]for (const day of dayjs.range('2020-12-01', '2020-12-31')) {
...
}
``````ts
dayjs.range("2020-12-01", "2020-12-12", {
step: [2, "day"],
});
```## Options
`dayjs.range()` accepts options as the 3rd argument.
### `excludeEnd`: boolean (optional)
Whether to exclude the last date from range.
### `step`: [number, string] (optional)
Step between each date. Accepts the same type as `dayjs.add()` ( For example, `[2, 'day']` ).