(now: Date, window: MaintenanceWindow)
| 93 | * collapse to `now`. Fire-now is gated by `inWindow`, not this function. |
| 94 | */ |
| 95 | export const nextWindowStart = (now: Date, window: MaintenanceWindow): Date => { |
| 96 | const s = toMinutes(window.start); |
| 97 | if (s == null) return now; |
| 98 | const isUtc = window.tz === 'utc'; |
| 99 | const year = isUtc ? now.getUTCFullYear() : now.getFullYear(); |
| 100 | const month = isUtc ? now.getUTCMonth() : now.getMonth(); |
| 101 | const day = isUtc ? now.getUTCDate() : now.getDate(); |
| 102 | const todayStart = buildAt(year, month, day, s, window.tz); |
| 103 | if (todayStart.getTime() > now.getTime()) return todayStart; |
| 104 | return buildAt(year, month, day + 1, s, window.tz); |
| 105 | }; |
no test coverage detected