pub struct Period { /* private fields */ }Expand description
How long a dashboard looks back: 7d, 30d, 90d (any number of days
up to 366), 12w (weeks up to 104), 12m (months up to 36), mtd (this
month so far), ytd (this year so far), or a custom range of dates
(2026-09-01..2026-09-30, both days included, at most 1,096 days), in
APP_TIMEZONE.
As an extractor it reads ?period=, or ?period=custom&from=2026-09-01&to=2026-09-30
(what the kit’s period_filter sends for a custom range); anything it
can’t read (an unknown key, a date that isn’t one, from after to, a
range over three years) gives the default, 30 days. It serializes as its
key ("30d", "2026-09-01..2026-09-30"), which period_filter takes.
Implementations§
Source§impl Period
impl Period
Sourcepub fn weeks(n: u32) -> Self
pub fn weeks(n: u32) -> Self
The last n weeks, this one so far included: from the Monday n - 1
weeks before this week’s Monday, to today. Per week.
Sourcepub fn month_to_date() -> Self
pub fn month_to_date() -> Self
This month so far.
Sourcepub fn year_to_date() -> Self
pub fn year_to_date() -> Self
This year so far.
Sourcepub fn between(from: NaiveDate, to: NaiveDate) -> Option<Self>
pub fn between(from: NaiveDate, to: NaiveDate) -> Option<Self>
From from to to, both days included (local days in
APP_TIMEZONE). None when from is after to or the range is
longer than 1,096 days (three years).
Sourcepub fn per(self, bucket: Bucket) -> Self
pub fn per(self, bucket: Bucket) -> Self
The same period, but per bucket instead of the step it picks
itself (bucket): Period::days(90).per(Bucket::Week).
Sourcepub fn parse(key: &str) -> Option<Self>
pub fn parse(key: &str) -> Option<Self>
"7d", "12w", "12m", "mtd", "ytd" or "2026-09-01..2026-09-30";
None for anything else.
Sourcepub fn key(&self) -> String
pub fn key(&self) -> String
The key it parses from: "30d", or "2026-09-01..2026-09-30" for a
custom range.
Sourcepub fn previous(self) -> Self
pub fn previous(self) -> Self
The period just before, as long: the 30 days before the last 30, last
month to the same day, last year to the same day, as many days just
before a custom range. For comparisons (Series::change_from).
Sourcepub fn bucket(&self) -> Bucket
pub fn bucket(&self) -> Bucket
Per day up to 92 days (and month to date), per week for 12w-style
periods and custom ranges up to 26 weeks, else per month; or what
per set.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more