Skip to main content

Period

Struct Period 

Source
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

Source

pub fn days(n: u32) -> Self

The last n days, today included.

Source

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.

Source

pub fn months(n: u32) -> Self

The last n months, this one included.

Source

pub fn month_to_date() -> Self

This month so far.

Source

pub fn year_to_date() -> Self

This year so far.

Source

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).

Source

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).

Source

pub fn parse(key: &str) -> Option<Self>

"7d", "12w", "12m", "mtd", "ytd" or "2026-09-01..2026-09-30"; None for anything else.

Source

pub fn key(&self) -> String

The key it parses from: "30d", or "2026-09-01..2026-09-30" for a custom range.

Source

pub fn is_custom(&self) -> bool

Whether it is a custom range of dates (between).

Source

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).

Source

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.

Source

pub fn range(&self, zone: Zone) -> (DateTime, DateTime)

The moments the period starts at and ends before, in zone.

Source

pub fn labels(&self, zone: Zone) -> Vec<String>

The labels of its buckets, in order: 2026-10-02 per day, the week’s Monday (2026-09-28) per week, 2026-10 per month.

Trait Implementations§

Source§

impl Clone for Period

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 Copy for Period

Source§

impl Debug for Period

Source§

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

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

impl Default for Period

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Period

Source§

impl<S: Send + Sync> FromRequestParts<S> for Period

Source§

type Rejection = !

If the extractor fails it’ll use this “rejection” type. A rejection is a kind of error that can be converted into a response.
Source§

async fn from_request_parts( parts: &mut Parts, _: &S, ) -> Result<Self, Self::Rejection>

Perform the extraction.
Source§

impl PartialEq for Period

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 Serialize for Period

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Period

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: RngExt + ?Sized, Self: FakeBase<U>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<S, T> FromRequest<S, ViaParts> for T
where S: Send + Sync, T: FromRequestParts<S>,

Source§

type Rejection = <T as FromRequestParts<S>>::Rejection

If the extractor fails it’ll use this “rejection” type. A rejection is a kind of error that can be converted into a response.
Source§

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>

Perform the extraction.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more