MCPcopy Create free account
hub / github.com/Effect-TS/effect / dayOfWeek

Function dayOfWeek

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

Source from the content-addressed store, hash-verified

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