pub struct WorkingTime { /* private fields */ }Expand description
Working spans of one calendar within a window, or every hour for the always calendar.
Implementations§
Source§impl WorkingTime
impl WorkingTime
Sourcepub fn add(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
pub fn add(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
Earliest time by which hours of working time after t have passed.
Sourcepub fn add_late(
&self,
t: f64,
hours_of_work: f64,
) -> Result<f64, BeyondCalendar>
pub fn add_late( &self, t: f64, hours_of_work: f64, ) -> Result<f64, BeyondCalendar>
Latest time at which hours of working time after t have passed: past a span’s end it
is the next span’s start, the same working instant.
Sourcepub fn sub(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
pub fn sub(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
Latest time from which hours of working time reach t.
Sourcepub fn shift(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
pub fn shift(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
A signed lag forwards: add for a non-negative amount and sub for a negative one.
Sourcepub fn unshift(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
pub fn unshift(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
The latest time whose forward shift by hours is at most t.
Sourcepub fn align(&self, t: f64) -> Result<f64, BeyondCalendar>
pub fn align(&self, t: f64) -> Result<f64, BeyondCalendar>
Earliest working moment at or after t; span ends count as working.
Sourcepub fn next_working(&self, t: f64) -> Result<f64, BeyondCalendar>
pub fn next_working(&self, t: f64) -> Result<f64, BeyondCalendar>
Earliest moment at or after t that working time follows; a span’s end moves to the next
span, so work starting there is placed where it actually begins.
Sourcepub fn place(
&self,
t: f64,
hours_of_work: f64,
) -> Result<(f64, f64), BeyondCalendar>
pub fn place( &self, t: f64, hours_of_work: f64, ) -> Result<(f64, f64), BeyondCalendar>
Where work of hours starting no earlier than t runs: its start, the first moment that
working time follows, and its end, the earliest time the hours have passed. Equal to
next_working then add, with one lookup when the work fits in one span.
Sourcepub fn retreat(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
pub fn retreat(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>
The latest start from which hours of work end by align_back(t): equal to align_back
then sub, with one lookup when the work fits in one span.
Sourcepub fn align_back(&self, t: f64) -> Result<f64, BeyondCalendar>
pub fn align_back(&self, t: f64) -> Result<f64, BeyondCalendar>
Latest moment at or before t whose align is not after t.
Source§impl WorkingTime
impl WorkingTime
Sourcepub fn compile(
rules: CalendarRules<'_>,
zone: Tz,
origin: DateTime<Utc>,
from: f64,
until: f64,
) -> Option<Self>
pub fn compile( rules: CalendarRules<'_>, zone: Tz, origin: DateTime<Utc>, from: f64, until: f64, ) -> Option<Self>
Compile the local dates covering hours from..=until after origin; None when the
window is longer than MAX_WINDOW_HOURS or outside chrono’s range.
Sourcepub fn offset_after(
rules: CalendarRules<'_>,
zone: Tz,
from: DateTime<Utc>,
hours: f64,
) -> Option<f64>
pub fn offset_after( rules: CalendarRules<'_>, zone: Tz, from: DateTime<Utc>, hours: f64, ) -> Option<f64>
Hours after from at which hours of working time have passed, compiling wider windows
until the answer is inside one. None when the calendar has no working time left within
MAX_WINDOW_HOURS.