// Pure helpers for the cross-platform "pause notifications" / snooze feature.
// Kept free of jotai/localStorage so they're unit-testable in isolation; the
// persisted atom lives in state/notificationSnooze.ts.

// Represents "paused until I turn it back on" (a far-future instant).
export const SNOOZE_INDEFINITE = Number.MAX_SAFE_INTEGER;

// Is the snooze currently active (i.e. suppressing notifications)?
export function isSnoozeActive(until: number, now: number = Date.now()): boolean {
  return until > now;
}

// The soonest future instant at the given local hour (0-23), minute 0 — used for
// the "Until 8 AM" preset. If that hour has already passed today, rolls to
// tomorrow.
export function nextTimeAtHour(hour: number, now: number = Date.now()): number {
  const d = new Date(now);
  d.setHours(hour, 0, 0, 0);
  if (d.getTime() <= now) d.setDate(d.getDate() + 1);
  return d.getTime();
}
