getNextHourTime zu shared library hinzugefügt
This commit is contained in:
16
packages/shared-components/helper/dates.ts
Normal file
16
packages/shared-components/helper/dates.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { set, isBefore, addDays } from "date-fns";
|
||||
|
||||
export function getNextDateWithTime(targetHour: number, targetMinute: number): Date {
|
||||
const now = new Date();
|
||||
let targetDate = set(now, {
|
||||
hours: targetHour,
|
||||
minutes: targetMinute,
|
||||
seconds: 0,
|
||||
milliseconds: 0,
|
||||
});
|
||||
if (!isBefore(now, targetDate)) {
|
||||
targetDate = addDays(targetDate, 1);
|
||||
}
|
||||
|
||||
return targetDate;
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./cn";
|
||||
export * from "./event";
|
||||
export * from "./dates";
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"@repo/typescript-config": "workspace:*",
|
||||
"@types/node": "^22.15.29",
|
||||
"clsx": "^2.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"tailwind-merge": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user