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

Function match

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

Source from the content-addressed store, hash-verified

712 * @since 2.0.0
713 */
714export const match = (cron: Cron, date: DateTime.DateTime.Input): boolean => {
715 const parts = dateTime.makeZonedUnsafe(date, {
716 timeZone: Option.getOrUndefined(cron.tz)
717 }).pipe(dateTime.toParts)
718
719 if (cron.seconds.size !== 0 && !cron.seconds.has(parts.second)) {
720 return false
721 }
722
723 if (cron.minutes.size !== 0 && !cron.minutes.has(parts.minute)) {
724 return false
725 }
726
727 if (cron.hours.size !== 0 && !cron.hours.has(parts.hour)) {
728 return false
729 }
730
731 if (cron.months.size !== 0 && !cron.months.has(parts.month)) {
732 return false
733 }
734
735 if (cron.days.size === 0 && cron.weekdays.size === 0) {
736 return true
737 }
738
739 if (cron.and) {
740 return (cron.days.size === 0 || cron.days.has(parts.day)) &&
741 (cron.weekdays.size === 0 || cron.weekdays.has(parts.weekDay))
742 }
743
744 if (cron.weekdays.size === 0) {
745 return cron.days.has(parts.day)
746 }
747
748 if (cron.days.size === 0) {
749 return cron.weekdays.has(parts.weekDay)
750 }
751
752 return cron.days.has(parts.day) || cron.weekdays.has(parts.weekDay)
753}
754
755const daysInMonth = (date: Date): number =>
756 new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth() + 1, 0)).getUTCDate()

Callers 11

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
effect.tsFile · 0.50
matcher.tsFile · 0.50
typeTagsFunction · 0.50

Calls 2

pipeMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected