Module fieldsets

Source
Expand description

All available field sets for datetime formatting.

Each field set is a struct containing options specified to that field set. The fields can either be set directly or via helper functions.

This module contains static field sets, which deliver the smallest binary size. If the field set is not known until runtime, use a dynamic field set: enums

§What is a Field Set?

A field set determines what datetime fields should be printed in the localized output.

Examples of field sets include:

  1. Year, month, and day (YMD)
  2. Weekday and time (ET)

Field sets fit into four categories:

  1. Date: fields that specify a particular day in time.
  2. Calendar period: fields that specify a span of time greater than a day.
  3. Time: fields that specify a time within a day.
  4. Zone: fields that specify a time zone or offset from UTC.

Certain combinations of field sets are allowed, too. See Combo.

§Examples

There are two ways to configure the same field set:

use icu::datetime::fieldsets::YMDT;
use icu::datetime::options::{Alignment, TimePrecision, YearStyle};

let field_set_1 = YMDT::long()
    .with_year_style(YearStyle::Full)
    .with_alignment(Alignment::Column)
    .with_time_precision(TimePrecision::Minute);

let mut field_set_2 = YMDT::long();
field_set_2.year_style = Some(YearStyle::Full);
field_set_2.alignment = Some(Alignment::Column);
field_set_2.time_precision = Some(TimePrecision::Minute);

assert_eq!(field_set_1, field_set_2);

Modules§

builder
Builder APIs for dynamic field sets.
enums
Enumerations over field sets.
zone
Time zone field sets

Structs§

Combo
Struct for combining date/time fields with zone fields.
D
“17” ⇒ day of month (standalone)
DE
“17 Friday” ⇒ day of month and weekday
DET
“17 Friday, 3:47:50 PM” ⇒ day of month and weekday with time
DT
“17, 3:47:50 PM” ⇒ day of month (standalone) with time
E
“Friday” ⇒ weekday (standalone)
ET
“Friday 3:47:50 PM” ⇒ weekday (standalone) with time
M
“May” ⇒ month (standalone)
MD
“May 17” ⇒ month and day
MDE
“Fri, May 17” ⇒ month, day, and weekday
MDET
“Fri, May 17, 3:47:50 PM” ⇒ month, day, and weekday with time
MDT
“May 17, 3:47:50 PM” ⇒ month and day with time
T
“3:47:50 PM” ⇒ time (locale-dependent hour cycle)
Y
“2024” ⇒ year (standalone)
YM
“May 2024” ⇒ year and month
YMD
“5/17/24” ⇒ year, month, and day
YMDE
“Fri, 5/17/24” ⇒ year, month, day, and weekday
YMDET
“Fri, 5/17/24, 3:47:50 PM” ⇒ year, month, day, and weekday with time
YMDT
“5/17/24, 3:47:50 PM” ⇒ year, month, and day with time