Hyperlinkv0.8.0-beta.28

Cron

Cron.Equivalenceconsteffect/Cron.ts:1042
(self: Cron, that: Cron): boolean

Equivalence instance for comparing the field restrictions of two Cron schedules.

When to use

Use to compare cron schedules through APIs that accept an equivalence relation.

Details

This comparison checks seconds, minutes, hours, days, months, and weekdays. It does not compare the optional timezone.

Example (Comparing schedules with equivalence)

import { Cron } from "effect"

const cron1 = Cron.make({
  minutes: [0, 30],
  hours: [9],
  days: [1, 15],
  months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
  weekdays: [1, 2, 3, 4, 5]
})

const cron2 = Cron.make({
  minutes: [30, 0], // Different order
  hours: [9],
  days: [15, 1], // Different order
  months: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
  weekdays: [1, 2, 3, 4, 5]
})

console.log(Cron.Equivalence(cron1, cron2)) // true
instancesequals
Source effect/Cron.ts:10429 lines
export const Equivalence: Equ.Equivalence<Cron> = Equ.make((self, that) =>
  self.and === that.and &&
  restrictionsEquals(self.seconds, that.seconds) &&
  restrictionsEquals(self.minutes, that.minutes) &&
  restrictionsEquals(self.hours, that.hours) &&
  restrictionsEquals(self.days, that.days) &&
  restrictionsEquals(self.months, that.months) &&
  restrictionsEquals(self.weekdays, that.weekdays)
)
Referenced by 1 symbols