Skip to content

Commit dea16ee

Browse files
authored
fix: adjust date-fns dependency to accommodate date-fns-tz
fixes: #47 - adjusted date-fns dependency to `"^2.28.0 || ^3.0.0"` from `"^3.0.0"` to accommodate date-fns-tz - adjusted helper function to reflect version compatibility changes - removed old un-used helper functions
1 parent acc9436 commit dea16ee

File tree

3 files changed

+11
-45
lines changed

3 files changed

+11
-45
lines changed

package-lock.json

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"docs:serve": "vitepress serve docs"
2626
},
2727
"dependencies": {
28-
"date-fns": "^3.0.0",
28+
"date-fns": "^2.28.0 || ^3.0.0",
2929
"vue": "^3.3.12"
3030
},
3131
"devDependencies": {

src/helpers/DateHelper.ts

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,7 @@
11
import { addDays, startOfWeek, isWeekend, Day } from "date-fns";
22

3-
export function getWeekRange(
4-
date: Date | string,
5-
startDayOfWeek: number = 0
6-
): { start: Date; end: Date } {
7-
if (typeof date == typeof "string") {
8-
date = new Date(date + "T00:00:00");
9-
}
10-
const startDate = new Date(date);
11-
const endDate = new Date(date);
12-
// Calculate the difference from the start day of the week
13-
let dayDifference = startDate.getDay() - startDayOfWeek;
14-
15-
// Correct the day difference if the day is before the start day of the week
16-
if (dayDifference < 0) {
17-
dayDifference += 7;
18-
}
19-
20-
// Adjust the start and end dates
21-
startDate.setDate(startDate.getDate() - dayDifference);
22-
endDate.setDate(startDate.getDate() + 6);
23-
24-
// Ensure start and end dates are at the beginning and end of their respective days
25-
startDate.setHours(0, 0, 0, 0); // Set to start of the day
26-
endDate.setHours(23, 59, 59, 999); // Set to end of the day
27-
28-
return { start: startDate, end: endDate };
29-
}
30-
313
export function getWeekDays(
32-
date: Date | string,
4+
date: Date,
335
includeWeekends: boolean = true,
346
startDayOfWeek: Day = 0
357
): Date[] {
@@ -47,12 +19,3 @@ export function getWeekDays(
4719

4820
return weekDays;
4921
}
50-
51-
export function mergeTime(date: Date, time: Date) {
52-
const newDate = new Date(date);
53-
newDate.setHours(time.getHours());
54-
newDate.setMinutes(time.getMinutes());
55-
newDate.setSeconds(time.getSeconds());
56-
newDate.setMilliseconds(time.getMilliseconds());
57-
return newDate;
58-
}

0 commit comments

Comments
 (0)