Skip to content

Commit 7c4be2c

Browse files
committed
Update version to 4.3.2, add step option to date range series, and document changes in CHANGELOG.md
1 parent de91507 commit 7c4be2c

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# deverything
22

3+
## 4.3.2
4+
5+
### Patch Changes
6+
7+
- step option in date range series
8+
39
## 4.3.1
410

511
### Patch Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deverything",
3-
"version": "4.3.1",
3+
"version": "4.3.2",
44
"description": "Everything you need for Dev",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/dates/getDateRangeSeries.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import { DateRange, ISODate } from "../types";
88
*/
99
export const getDateRangeSeries = (
1010
dateRange: DateRange,
11-
unit: "day" | "week" | "hour" | "minute" | "second" | "calendarMonth"
11+
unit: "day" | "week" | "hour" | "minute" | "second" | "calendarMonth",
12+
options: {
13+
step?: number;
14+
} = {}
1215
): ISODate[] => {
1316
const { startDate, endDate } = dateRange;
1417

@@ -22,6 +25,8 @@ export const getDateRangeSeries = (
2225
const series: string[] = [];
2326
const current = new Date(start.getTime()); // Clone the startDate to avoid mutating it
2427

28+
const step = options?.step ?? 1;
29+
2530
// eslint-disable-next-line no-unmodified-loop-condition
2631
while (current < end) {
2732
series.push(current.toISOString());
@@ -35,29 +40,29 @@ export const getDateRangeSeries = (
3540
}
3641
{
3742
const currentMonth = current.getUTCMonth();
38-
current.setUTCMonth(currentMonth + 1);
43+
current.setUTCMonth(currentMonth + step);
3944
}
4045

4146
break;
4247

4348
case "day":
44-
current.setUTCDate(current.getUTCDate() + 1);
49+
current.setUTCDate(current.getUTCDate() + step);
4550
break;
4651

4752
case "week":
48-
current.setUTCDate(current.getUTCDate() + 7);
53+
current.setUTCDate(current.getUTCDate() + step * 7);
4954
break;
5055

5156
case "hour":
52-
current.setUTCHours(current.getUTCHours() + 1);
57+
current.setUTCHours(current.getUTCHours() + step);
5358
break;
5459

5560
case "minute":
56-
current.setUTCMinutes(current.getUTCMinutes() + 1);
61+
current.setUTCMinutes(current.getUTCMinutes() + step);
5762
break;
5863

5964
case "second":
60-
current.setUTCSeconds(current.getUTCSeconds() + 1);
65+
current.setUTCSeconds(current.getUTCSeconds() + step);
6166
break;
6267

6368
default:

0 commit comments

Comments
 (0)