pub struct LocaleFormatters { /* private fields */ }Expand description
Reusable ICU4X formatters bound to one explicit locale.
Construct this type when the selected formatting locale changes, then reuse it for display values. The locale controls language, calendar conventions, numbering system, separators, date order, and currency placement. Formatting only changes presentation; it never changes stored dates, currency codes, or monetary values.
Implementations§
Source§impl LocaleFormatters
impl LocaleFormatters
Sourcepub fn new(locale: &Locale) -> Result<LocaleFormatters, FormatError>
pub fn new(locale: &Locale) -> Result<LocaleFormatters, FormatError>
Creates reusable formatters for the selected locale.
Sourcepub fn format_year_month(
&self,
year: i32,
month: u8,
) -> Result<String, FormatError>
pub fn format_year_month( &self, year: i32, month: u8, ) -> Result<String, FormatError>
Formats a Gregorian year and month with localized month names and ordering.
Sourcepub fn format_date(
&self,
year: i32,
month: u8,
day: u8,
) -> Result<String, FormatError>
pub fn format_date( &self, year: i32, month: u8, day: u8, ) -> Result<String, FormatError>
Formats a Gregorian date using the locale’s date order and conventions.
Sourcepub fn format_long_date(
&self,
year: i32,
month: u8,
day: u8,
) -> Result<String, FormatError>
pub fn format_long_date( &self, year: i32, month: u8, day: u8, ) -> Result<String, FormatError>
Formats a Gregorian date in full, with its weekday, as a screen reader reads a day out: “Wednesday, October 14, 2026”.
Sourcepub fn format_weekday(
&self,
year: i32,
month: u8,
day: u8,
) -> Result<String, FormatError>
pub fn format_weekday( &self, year: i32, month: u8, day: u8, ) -> Result<String, FormatError>
The short name of the weekday a Gregorian date falls on: “Wed”, “ср”.
Sourcepub fn first_weekday(&self) -> u8
pub fn first_weekday(&self) -> u8
The day the locale’s week starts on, 1 for Monday through 7 for Sunday.
Sourcepub fn format_time(&self, hour: u8, minute: u8) -> Result<String, FormatError>
pub fn format_time(&self, hour: u8, minute: u8) -> Result<String, FormatError>
Formats a time of day on the locale’s clock: “9:05 PM”, “21:05”.
Sourcepub fn uses_24_hour_clock(&self) -> bool
pub fn uses_24_hour_clock(&self) -> bool
Whether the locale’s clock runs through 24 hours rather than twice through 12: 1:00 and 13:00 then show different hours.
Sourcepub fn day_periods(&self) -> Result<[String; 2], FormatError>
pub fn day_periods(&self) -> Result<[String; 2], FormatError>
The names of the two halves of a 12-hour day, before and after noon: “AM” and “PM”, “오전” and “오후”. They are what a 12-hour time shows beside its digits.
Sourcepub fn format_decimal(
&self,
value: f64,
fraction_digits: u8,
) -> Result<String, FormatError>
pub fn format_decimal( &self, value: f64, fraction_digits: u8, ) -> Result<String, FormatError>
Formats a decimal with locale-specific digits and separators at fixed precision.
fraction_digits may range from zero through eighteen.
Sourcepub fn format_percent(
&self,
ratio: f64,
fraction_digits: u8,
) -> Result<String, FormatError>
pub fn format_percent( &self, ratio: f64, fraction_digits: u8, ) -> Result<String, FormatError>
Formats a ratio as a localized percentage; for example, 0.125 represents 12.5%.
fraction_digits may range from zero through eighteen.
Sourcepub fn format_currency(
&self,
amount: f64,
currency_code: &str,
) -> Result<String, FormatError>
pub fn format_currency( &self, amount: f64, currency_code: &str, ) -> Result<String, FormatError>
Formats a monetary amount in the locale using an uppercase ISO 4217 code.
This method applies currency-specific display precision and placement. It does not convert the amount or alter its currency.
Auto Trait Implementations§
impl !Freeze for LocaleFormatters
impl !Send for LocaleFormatters
impl !Sync for LocaleFormatters
impl RefUnwindSafe for LocaleFormatters
impl Unpin for LocaleFormatters
impl UnsafeUnpin for LocaleFormatters
impl UnwindSafe for LocaleFormatters
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<T> ErasedDestructor for Twhere
T: 'static,
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