"use client";
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;
}
