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: RegionFormatsImplementations§
§impl Formats
impl Formats
pub fn day_fact(
&self,
day: NaiveDate,
time: Option<NaiveTime>,
today: NaiveDate,
) -> DayFact
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
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
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
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
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
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
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
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
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
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
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
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
pub fn month_heading(&self, day: NaiveDate) -> String
The month heading style, for a month grid: June 2026.
pub fn month_day_year(&self, day: NaiveDate) -> String
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
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
pub fn weekday_short(&self, day: Weekday) -> String
The abbreviated weekday: Sun.
pub fn weekday_name(&self, day: Weekday) -> String
pub fn weekday_name(&self, day: Weekday) -> String
The weekday’s name: Sunday.
pub fn month_short(&self, month: u32) -> String
pub fn month_short(&self, month: u32) -> String
The abbreviated month (1 = January): Jun.
pub fn month_name(&self, month: u32) -> String
pub fn month_name(&self, month: u32) -> String
The month’s name (1 = January): June.
§impl Formats
impl Formats
pub const fn with(region: RegionFormats) -> Formats
pub const fn with(region: RegionFormats) -> Formats
Explicit formats, for tests and previews.
pub fn money(&self, micros: u64) -> String
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
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
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
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
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
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
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)
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).
Trait Implementations§
impl Copy for Formats
impl Eq for Formats
impl StructuralPartialEq for Formats
Auto Trait Implementations§
impl Freeze for Formats
impl RefUnwindSafe for Formats
impl Send for Formats
impl Sync for Formats
impl Unpin for Formats
impl UnsafeUnpin for Formats
impl UnwindSafe for Formats
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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 Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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