pub struct Period {
pub unit: Unit,
pub start: NaiveDateTime,
}Expand description
A calendar-aligned span of local time: one hour, day, ISO week (Mon–Sun) or month.
Fields§
§unit: UnitHow long the period is.
start: NaiveDateTimeIts first moment, in local time (e.g. Monday 00:00 for a week).
Implementations§
Source§impl Period
impl Period
Sourcepub fn containing(unit: Unit, at: NaiveDateTime) -> Self
pub fn containing(unit: Unit, at: NaiveDateTime) -> Self
The period of length unit that contains at.
Sourcepub fn end(self) -> NaiveDateTime
pub fn end(self) -> NaiveDateTime
The first moment after the period (the start of the next one).
Sourcepub fn contains(self, at: NaiveDateTime) -> bool
pub fn contains(self, at: NaiveDateTime) -> bool
Whether at falls inside the period.
Sourcepub fn with_unit(self, unit: Unit) -> Self
pub fn with_unit(self, unit: Unit) -> Self
Switches unit, staying around “now” if this period contains it.
Sourcepub fn bounds(self) -> (DateTime<Local>, DateTime<Local>)
pub fn bounds(self) -> (DateTime<Local>, DateTime<Local>)
The period as a [start, end) range of local times.
Trait Implementations§
impl Copy for Period
impl Eq for Period
impl StructuralPartialEq for Period
Auto Trait Implementations§
impl Freeze for Period
impl RefUnwindSafe for Period
impl Send for Period
impl Sync for Period
impl Unpin for Period
impl UnsafeUnpin for Period
impl UnwindSafe for Period
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.