MCPcopy Create free account
hub / github.com/effect-app/libs / match

Function match

repos/effect/packages/effect/src/Cron.ts:660–694  ·  view source on GitHub ↗
(cron: Cron, date: DateTime.DateTime.Input)

Source from the content-addressed store, hash-verified

658 const segments: Array<string> = []
659 let index = 0
660 while (index < array.length) {
661 const start = array[index]!
662 const step = array[index + 1]! - start
663 if (index + 2 < array.length && array[index + 2]! - array[index + 1]! === step) {
664 let end = index + 2
665 while (end + 1 < array.length && array[end + 1]! - array[end]! === step) {
666 end++
667 }
668 segments.push(`${start}-${array[end]}${step === 1 ? "" : `/${step}`}`)
669 index = end + 1
670 } else {
671 segments.push(`${start}`)
672 index++
673 }
674 }
675 return segments.join(",")
676}
677
678/**
679 * Returns `true` when a date/time matches a `Cron` schedule.
680 *
681 * **When to use**
682 *
683 * Use to test whether a specific date/time satisfies a cron schedule.
684 *
685 * **Details**
686 *
687 * The schedule's timezone determines which calendar fields are read from the
688 * input; the host system's timezone is used when the schedule has no timezone.
689 * Seconds, minutes, hours, and months are checked against their restrictions;
690 * an empty set leaves that field unrestricted. If only `days` or `weekdays` is
691 * restricted, that field must match. If both are restricted, either may match
692 * unless the schedule was created with `and: true`, which requires both to
693 * match.
694 *
695 * **Example** (Matching dates against a schedule)
696 *
697 * ```ts import.meta.vitest

Callers 15

Result.tsFile · 0.70
toMillisFunction · 0.70
toSecondsFunction · 0.70
toMinutesFunction · 0.70
toHoursFunction · 0.70
toDaysFunction · 0.70
toWeeksFunction · 0.70
Duration.tsFile · 0.70
effectFunction · 0.50
effectFunction · 0.50
effectFunction · 0.50
effectFunction · 0.50

Calls 2

pipeMethod · 0.65
hasMethod · 0.45

Tested by 6

effectFunction · 0.40
effectFunction · 0.40
effectFunction · 0.40
effectFunction · 0.40
effectFunction · 0.40
effectFunction · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…