effect-io-ai

Package: effect
Module: Cron

Cron.Equivalence

Equivalence instance for comparing the timezone, field restrictions, and day-matching mode of two Cron schedules.

When to use

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

Details

This comparison checks the optional timezone, the and day-matching mode, seconds, minutes, hours, days, months, and weekdays.

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

See

Signature

declare const Equivalence: Equ.Equivalence<Cron>

Source

Since v2.0.0