pub enum Period {
CalendarMonthUtc,
Anchored {
anchor: OffsetDateTime,
every: Months,
},
Day,
}Expand description
How a period is cut. Every variant converts to UTC first, so an instant in any offset names the same window as its UTC spelling.
Variants§
CalendarMonthUtc
The UTC calendar month.
Anchored
A cycle anchored on a subscription’s start: period k starts at
anchor + k * every months, recomputed from the anchor every time,
never chained, the day clamped to the target month’s last day and the
anchor’s UTC time-of-day kept. An anchor on Jan 31 gives Feb 28 (Feb 29
in a leap year), then Mar 31, then Apr 30 — each clamp remembered only
for the month that needs it. A now before the anchor uses floor
division (a negative k).
Day
The UTC calendar day.
Implementations§
Source§impl Period
impl Period
Sourcepub fn window_at(self, now: OffsetDateTime) -> PeriodWindow
pub fn window_at(self, now: OffsetDateTime) -> PeriodWindow
The window containing now.
Sourcepub fn index_at(self, now: OffsetDateTime) -> i64
pub fn index_at(self, now: OffsetDateTime) -> i64
The period index containing now: what window_for
inverts and what history and purge step over.
Sourcepub fn window_for(self, index: i64) -> PeriodWindow
pub fn window_for(self, index: i64) -> PeriodWindow
The window with this index: window_for(index_at(now)) == window_at(now).
An index at either extreme of the i64 range saturates rather than
overflowing (see month_index_bounds).
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
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
key and return true if they are equal.