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

Function dayOfMonth

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

Source from the content-addressed store, hash-verified

524
525/** @internal */
526export const dayOfMonth = (day: number): Schedule.Schedule<number> => {
527 return makeWithState<[number, number], unknown, number>(
528 [Number.NEGATIVE_INFINITY, 0],
529 (now, _, state) => {
530 if (!Number.isInteger(day) || day < 1 || 31 < day) {
531 return core.dieSync(() =>
532 new core.IllegalArgumentException(
533 `Invalid argument in: dayOfMonth(${day}). Must be in range 1...31`
534 )
535 )
536 }
537 const n = state[1]
538 const initial = n === 0
539 const day0 = nextDayOfMonth(now, day, initial)
540 const start = beginningOfDay(day0)
541 const end = endOfDay(day0)
542 const interval = Interval.make(start, end)
543 return core.succeed(
544 [
545 [end, n + 1],
546 n,
547 ScheduleDecision.continueWith(interval)
548 ]
549 )
550 }
551 )
552}
553
554/** @internal */
555export const dayOfWeek = (day: number): Schedule.Schedule<number> => {

Callers

nothing calls this directly

Calls 5

makeWithStateFunction · 0.85
nextDayOfMonthFunction · 0.85
beginningOfDayFunction · 0.85
endOfDayFunction · 0.85
makeMethod · 0.65

Tested by

no test coverage detected