getNextHourTime zu shared library hinzugefügt

This commit is contained in:
PxlLoewe
2025-06-27 22:54:31 -07:00
parent dc92174798
commit ec22cdb987
14 changed files with 89 additions and 62 deletions

View 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;
}