Skip to main content

Formats

Struct Formats 

pub struct Formats {
    pub region: RegionFormats,
}
Expand description

One set of formats: the person’s RegionFormats. Words (month names, “Yesterday”, plurals) come from the language active on the calling thread.

Fields§

§region: RegionFormats

Implementations§

§

impl Formats

pub fn day_fact( &self, day: NaiveDate, time: Option<NaiveTime>, today: NaiveDate, ) -> DayFact

The day fact style: a calendar day as a heading, a row’s trailing fact or a card reads it, by how far day is from today. A day gone by says which day it was and that it is Overdue (Overdue since Jun 29), in the overdue tone; today and tomorrow are named; the week ahead its weekday (Thursday); this year the month and day (Jun 29); other years the full date (Jun 29, 2025). Given a time, the day and the time read as one fact (Today 09:00, Thu 14:30, Jun 29 09:00); a day gone by keeps its date there too (Overdue since Jun 29 14:30), because a fact says when it is, and “Yesterday” alone would not say which day of the month is late.

The day is the person’s own: today is crate::clock::today.

pub fn moment_fact(&self, at: NaiveDateTime, today: NaiveDate) -> String

The moment fact style: a moment told beside words that already name its day, as a choice’s trailing fact reads it. It is always the time of day (15:00), with the short weekday before it when it is not today (Sat 09:00), the month and day past the week ahead (Jun 29 09:00), and the year with another year’s day (Jan 2, 2027 09:00).

The day is the person’s own: today is crate::clock::today.

pub fn day_done(&self, day: NaiveDate, today: NaiveDate) -> String

The day it happened style: a day something was done on, as the heading over what was done that day reads it. It is the day fact’s words without its judgement of the day’s direction: Today, Yesterday, the weekday within the past week (Sunday), this year the month and day (Jun 21), other years the full date (Jun 21, 2025). A day gone by is never Overdue here: what was finished is history, not a problem.

pub fn list_date(&self, at: NaiveDateTime, now: NaiveDateTime) -> String

The list style: as compact as a list column allows, by how far at is from now. Today shows the time (16:02), the days next to today their name (Yesterday, Tomorrow), the rest of the past week its weekday (Sun), this year the month and day (Jun 30), and other years the full date (Jun 30, 2025).

pub fn timestamp(&self, at: NaiveDateTime) -> String

The timestamp style: the date in the person’s date style and the time in their clock style. By default the language’s convention (Jun 30, 2026, 13:42, 30.06.2026, 13:42), or the style they chose (2026-06-30 13:42, 30 Jun 2026, 1:42 PM).

pub fn date(&self, day: NaiveDate) -> String

The date style: a calendar day in the person’s date style. By default the language’s convention (Jun 30, 2026, 30.06.2026), or the style they chose (2026-06-30, 06/30/2026, 30/06/2026, 30 Jun 2026).

pub fn language_date(&self, day: NaiveDate) -> String

A calendar day in the desktop language’s own convention, whatever date style is chosen: Jun 30, 2026 in English, 30.06.2026 in German. For values that carry “follow the language” as their own format (a spreadsheet cell’s).

pub fn time(&self, time: &impl Timelike) -> String

A time of day in the person’s clock style: 14:05 or 2:05 PM.

pub fn day_heading(&self, day: NaiveDate, with_year: bool) -> String

The day heading style, for the top of a day, a lock screen or a detail view: Tuesday, June 30 (Tuesday, June 30, 2026 with with_year).

pub fn day_heading_short(&self, day: NaiveDate) -> String

The short day heading, for a day column or a compact header: Tue, Jun 30.

pub fn day_range(&self, start: NaiveDate, end: NaiveDate) -> String

A span of days, its month named once when it is the same: Jun 23 – 29, Jun 29 – Jul 5, Dec 29, 2025 – Jan 4, 2026.

pub fn month_heading_short(&self, day: NaiveDate) -> String

A month in a tight space: Jun 2026.

pub fn month_heading(&self, day: NaiveDate) -> String

The month heading style, for a month grid: June 2026.

pub fn month_day(&self, day: NaiveDate) -> String

Month and day without the year: Jun 30.

pub fn month_day_year(&self, day: NaiveDate) -> String

Month, day and year with the month named: Jun 30, 2025.

pub fn month_day_time(&self, at: NaiveDateTime) -> String

A day without its year and a time of day, for a list of recent moments: Jun 30, 14:05 in English, 30. Jun 14:05 in German. The year is left out because the list says which year it covers.

pub fn weekday_short(&self, day: Weekday) -> String

The abbreviated weekday: Sun.

pub fn weekday_name(&self, day: Weekday) -> String

The weekday’s name: Sunday.

pub fn month_short(&self, month: u32) -> String

The abbreviated month (1 = January): Jun.

pub fn month_name(&self, month: u32) -> String

The month’s name (1 = January): June.

pub fn week(&self) -> [Weekday; 7]

The week as the person’s calendars lay it out: seven weekdays from the first day they chose.

§

impl Formats

pub fn current() -> Formats

The person’s formats as their settings say now.

pub const fn with(region: RegionFormats) -> Formats

Explicit formats, for tests and previews.

pub fn count(&self, n: u64) -> String

The count style: a whole count with digit grouping (12,345).

pub fn money(&self, micros: u64) -> String

The money style: an amount in millionths of the currency, in the dollars model providers bill in ($5, $0.42, $1,250).

Whole amounts read without cents and fractional ones with two places, grouped and marked by the person’s number style.

pub fn items(&self, n: u64) -> String

A count of things in a folder, a selection or a result: 12 items.

pub fn decimal(&self, value: f64, digits: usize) -> String

The decimal style: value with digits fractional digits and the person’s separators (1,234.5, 1.234,5).

pub fn size(&self, n: u64) -> String

The size style: bytes stored or transferred, in SI decimal units (999 B, 1 kB, 1.5 MB).

pub fn memory(&self, n: u64) -> String

The memory style: bytes of memory, in IEC binary units (1,023 B, 1 KiB, 5 MiB).

pub fn memory_value(&self, value: f64, digits: usize) -> String

A signed amount of memory with digits fractional digits, for chart axes whose ticks need a fixed precision (-1.50 GiB).

pub fn rate(&self, bytes_per_sec: f64) -> String

A transfer rate from bytes per second, in SI decimal units like every transferred size (512 B/s, 6.7 MB/s). Negative rates read as zero.

pub fn rate_unit(&self, peak: f64) -> (f64, &'static str)

The rate unit a scale up to peak bytes per second reads in, and the bytes per second one of it is: (1e6, "MB/s") for 7.6 MB/s. For chart axes that label round numbers of one unit (Self::decimal writes the number).

pub fn duration(&self, duration: Duration) -> String

The duration style: an elapsed or remaining time in words, its two largest units (45 sec, 4 min 5 sec, 1 hr 5 min, 2 days 3 hr).

Trait Implementations§

§

impl Clone for Formats

§

fn clone(&self) -> Formats

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
§

impl Debug for Formats

§

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

Formats the value using the given formatter. Read more
§

impl Default for Formats

§

fn default() -> Formats

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

impl PartialEq for Formats

§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Copy for Formats

§

impl Eq for Formats

§

impl StructuralPartialEq for Formats

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

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

§

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

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

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

§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> CommonTraits for T
where T: AsAny + Any + Debug + WasmNotSendSync,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Fruit for T
where T: Send + Downcast,

§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T

§

impl<T> WasmNotSync for T
where T: Sync,