MCPcopy Create free account
hub / github.com/dailydotdev/apps / getWindowStartDay

Function getWindowStartDay

packages/shared/src/features/patchy/patchyTriggers.ts:12–29  ·  view source on GitHub ↗
(
  now: Date,
  { startHour, endHour }: PatchyHourWindow,
)

Source from the content-addressed store, hash-verified

10// whose start is after its end wraps past midnight (23 to 3), so its early
11// hours belong to the previous day.
12const getWindowStartDay = (
13 now: Date,
14 { startHour, endHour }: PatchyHourWindow,
15): Date | null => {
16 const hour = now.getHours();
17 if (startHour < endHour) {
18 return hour >= startHour && hour < endHour ? now : null;
19 }
20 if (hour >= startHour) {
21 return now;
22 }
23 if (hour < endHour) {
24 const previousDay = new Date(now);
25 previousDay.setDate(now.getDate() - 1);
26 return previousDay;
27 }
28 return null;
29};
30
31export const isLateNight = (now: Date, window: PatchyHourWindow): boolean =>
32 getWindowStartDay(now, window) !== null;

Callers 3

isLateNightFunction · 0.85
getNightKeyFunction · 0.85
isFridayDeployFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected