interval
ModuleUndocumented.
Contents
use utopia_schedule::Interval;Rust
pub struct IntervalA recurring trigger that fires every fixed number of seconds.
Occurrences sit on a deterministic grid, anchor + k × seconds, so the
cadence survives restarts instead of re-phasing to whenever the process
happened to boot. The anchor defaults to the Unix epoch; pass one to
phase the grid (for example to a resource's creation time).
Rust
use php_std::datetime::{DateTime, Timestamp, TzInfo};
use utopia_schedule::{Interval, Trigger};
let at = |s: &str| DateTime::parse(s.as_bytes(), None, &TzInfo::utc(), Timestamp { sec: 0, usec: 0 }).unwrap();
let quarterly = Interval::new(900, None)?;
let due = quarterly.occurrences_between(&at("2026-08-17 16:07:00"), &at("2026-08-17 16:35:00"));
let due: Vec<_> = due.iter().map(|d| String::from_utf8(d.format(b"H:i:s")).unwrap()).collect();
assert_eq!(due, ["16:15:00", "16:30:00"]);