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

Function hourOfDay

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

Source from the content-addressed store, hash-verified

832
833/** @internal */
834export const hourOfDay = (hour: number): Schedule.Schedule<number> =>
835 makeWithState<[number, number], unknown, number>(
836 [Number.NEGATIVE_INFINITY, 0],
837 (now, _, state) => {
838 if (!Number.isInteger(hour) || hour < 0 || 23 < hour) {
839 return core.dieSync(() =>
840 new core.IllegalArgumentException(
841 `Invalid argument in: hourOfDay(${hour}). Must be in range 0...23`
842 )
843 )
844 }
845 const n = state[1]
846 const initial = n === 0
847 const hour0 = nextHour(now, hour, initial)
848 const start = beginningOfHour(hour0)
849 const end = endOfHour(hour0)
850 const interval = Interval.make(start, end)
851 return core.succeed(
852 [
853 [end, n + 1],
854 n,
855 ScheduleDecision.continueWith(interval)
856 ]
857 )
858 }
859 )
860
861/** @internal */
862export 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