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

Function hourOfDay

packages/effect/src/internal/schedule.ts:826–851  ·  view source on GitHub ↗
(hour: number)

Source from the content-addressed store, hash-verified

824
825/** @internal */
826export const hourOfDay = (hour: number): Schedule.Schedule<number> =>
827 makeWithState<[number, number], unknown, number>(
828 [Number.NEGATIVE_INFINITY, 0],
829 (now, _, state) => {
830 if (!Number.isInteger(hour) || hour < 0 || 23 < hour) {
831 return core.dieSync(() =>
832 new core.IllegalArgumentException(
833 `Invalid argument in: hourOfDay(${hour}). Must be in range 0...23`
834 )
835 )
836 }
837 const n = state[1]
838 const initial = n === 0
839 const hour0 = nextHour(now, hour, initial)
840 const start = beginningOfHour(hour0)
841 const end = endOfHour(hour0)
842 const interval = Interval.make(start, end)
843 return core.succeed(
844 [
845 [end, n + 1],
846 n,
847 ScheduleDecision.continueWith(interval)
848 ]
849 )
850 }
851 )
852
853/** @internal */
854export const identity = <A>(): Schedule.Schedule<A, A> =>

Callers

nothing calls this directly

Calls 5

makeWithStateFunction · 0.85
nextHourFunction · 0.85
beginningOfHourFunction · 0.85
endOfHourFunction · 0.85
makeMethod · 0.65

Tested by

no test coverage detected