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;
|
||||
}
|
||||
Reference in New Issue
Block a user