MCPcopy Index your code
hub / github.com/Effect-TS/effect / dayOfWeek

Function dayOfWeek

packages/effect/src/internal/schedule.ts:547–573  ·  view source on GitHub ↗
(day: number)

Source from the content-addressed store, hash-verified

545
546/** @internal */
547export const dayOfWeek = (day: number): Schedule.Schedule<number> => {
548 return makeWithState<[number, number], unknown, number>(
549 [Number.MIN_SAFE_INTEGER, 0],
550 (now, _, state) => {
551 if (!Number.isInteger(day) || day < 1 || 7 < day) {
552 return core.dieSync(() =>
553 new core.IllegalArgumentException(
554 `Invalid argument in: dayOfWeek(${day}). Must be in range 1 (Monday)...7 (Sunday)`
555 )
556 )
557 }
558 const n = state[1]
559 const initial = n === 0
560 const day0 = nextDay(now, day, initial)
561 const start = beginningOfDay(day0)
562 const end = endOfDay(day0)
563 const interval = Interval.make(start, end)
564 return core.succeed(
565 [
566 [end, n + 1],
567 n,
568 ScheduleDecision.continueWith(interval)
569 ]
570 )
571 }
572 )
573}
574
575/** @internal */
576export const delayed = dual<

Callers

nothing calls this directly

Calls 5

makeWithStateFunction · 0.85
nextDayFunction · 0.85
beginningOfDayFunction · 0.85
endOfDayFunction · 0.85
makeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…