scheduledDrying.ts 540 B

1234567891011121314
  1. export type DryingStartMode = 'now' | 'delay' | 'at_time';
  2. // Returns the UTC ISO start instant for a drying run, or null for "start now".
  3. // atTime is the raw value of an <input type="datetime-local"> (local timezone).
  4. export function computeStartAfter(
  5. mode: DryingStartMode,
  6. delayMinutes: number,
  7. atTime: string,
  8. now: Date = new Date(),
  9. ): string | null {
  10. if (mode === 'now') return null;
  11. if (mode === 'delay') return new Date(now.getTime() + delayMinutes * 60_000).toISOString();
  12. return new Date(atTime).toISOString();
  13. }