Skip to main content

WorkingTime

Struct WorkingTime 

Source
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

Source

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.

Source

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.

Source

pub fn sub(&self, t: f64, hours_of_work: f64) -> Result<f64, BeyondCalendar>

Latest time from which hours of working time reach t.

Source

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.

Source

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.

Source

pub fn align(&self, t: f64) -> Result<f64, BeyondCalendar>

Earliest working moment at or after t; span ends count as working.

Source

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.

Source

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.

Source

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.

Source

pub fn align_back(&self, t: f64) -> Result<f64, BeyondCalendar>

Latest moment at or before t whose align is not after t.

Source

pub fn between(&self, a: f64, b: f64) -> Result<f64, BeyondCalendar>

Working hours between a and a later b.

Source§

impl WorkingTime

Source

pub fn always() -> Self

A calendar in which every hour is working time.

Source

pub fn is_always(&self) -> bool

Whether every hour is working time.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for WorkingTime

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WorkingTime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WorkingTime

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for WorkingTime

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.