mule/cron
Shared cron-scheduling helpers — the Oban.Cron analog (cron.ex),
used by the Cron and Reindexer plugins: minute-boundary cadence and
timezone-local calendar conversion (DateTime.now!(timezone)), with
non-UTC zones resolved through the OS timezone database via tzif.
Types
A resolved evaluation timezone. UTC converts directly off the fixed
offset without touching the database; anything else carries the loaded
TzDatabase.
pub opaque type LocalClock
Values
pub fn local_calendar(
clock clock: LocalClock,
now now: timestamp.Timestamp,
) -> Result(#(calendar.Date, calendar.TimeOfDay), String)
The wall-clock date and time-of-day of now in the clock’s timezone.
Errs only if the OS zoneinfo changed under a running VM (the zone was
probed at resolve time).
pub fn milliseconds_to_next_minute(
now now: timestamp.Timestamp,
) -> Int
Milliseconds until the next :00 minute boundary (cron.ex
interval_to_next_minute) — both plugins evaluate on that cadence.
pub fn resolve_timezone(
timezone timezone: String,
now now: timestamp.Timestamp,
) -> Result(LocalClock, String)
Resolve a timezone name once, up front — a bad zone should fail the
plugin’s START (Elixir’s :timezone schema validation raises at init),
not a tick. now probes that the zone actually resolves.
pub fn timezone(clock clock: LocalClock) -> String
The timezone name this clock was resolved for (stamped into cron job
meta as cron_tz).