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

Function cron

packages/effect/src/Schedule.ts:681–693  ·  view source on GitHub ↗
(expression: string | Cron.Cron, tz?: string | DateTime.TimeZone)

Source from the content-addressed store, hash-verified

679 (expression: Cron.Cron): Schedule<Duration.Duration, unknown, Cron.CronParseError>
680 (expression: string, tz?: string | DateTime.TimeZone): Schedule<Duration.Duration, unknown, Cron.CronParseError>
681} = (expression: string | Cron.Cron, tz?: string | DateTime.TimeZone) => {
682 const parsed = Cron.isCron(expression) ? Result.succeed(expression) : Cron.parse(expression, tz)
683 return fromStep(effect.map(effect.fromResult(parsed), (cron) => (now, _) => {
684 if (now === Number.POSITIVE_INFINITY) {
685 return Cause.done(Duration.zero)
686 }
687 return effect.sync(() => {
688 const next = Cron.next(cron, now).getTime()
689 const duration = Duration.millis(next - now)
690 return [duration, duration]
691 })
692 }))
693}
694
695/**
696 * Returns a schedule that recurs once after the specified duration.

Callers

nothing calls this directly

Calls 7

fromStepFunction · 0.85
nextMethod · 0.65
succeedMethod · 0.45
parseMethod · 0.45
mapMethod · 0.45
doneMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected