Module icu::datetime::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

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::MinuteExact);

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::MinuteExact);

assert_eq!(field_set_1, field_set_2);

Modules§

  • Enumerations over field sets.
  • 🚧 [Experimental] Types for dealing with serialization of semantic skeletons.

Structs§

  • Struct for combining date/time fields with zone fields.
  • “17” ⇒ day of month (standalone)
  • “17 Friday” ⇒ day of month and weekday
  • “17 Friday, 3:47:50 PM” ⇒ day of month and weekday with time
  • “17, 3:47:50 PM” ⇒ day of month (standalone) with time
  • “Friday” ⇒ weekday (standalone)
  • “Friday 3:47:50 PM” ⇒ weekday (standalone) with time
  • “Chicago Time” ⇒ time zone in location format
  • “May” ⇒ month (standalone)
  • “May 17” ⇒ month and day
  • “Fri, May 17” ⇒ month, day, and weekday
  • “Fri, May 17, 3:47:50 PM” ⇒ month, day, and weekday with time
  • “May 17, 3:47:50 PM” ⇒ month and day with time
  • “GMT-5” ⇒ UTC offset
  • “3:47:50 PM” ⇒ time (locale-dependent hour cycle)
  • “Central Time” ⇒ time zone in generic non-location format
  • “CT” ⇒ time zone in generic non-location format (only short)
  • “2024” ⇒ year (standalone)
  • “May 2024” ⇒ year and month
  • “5/17/24” ⇒ year, month, and day
  • “Fri, 5/17/24” ⇒ year, month, day, and weekday
  • “Fri, 5/17/24, 3:47:50 PM” ⇒ year, month, day, and weekday with time
  • “5/17/24, 3:47:50 PM” ⇒ year, month, and day with time
  • “Central Daylight Time” ⇒ time zone in specific non-location format
  • “CDT” ⇒ time zone in specific non-location format (only short)

Type Aliases§

  • “17 May 2024, 15:47:50 GMT+1” ⇒ locale-dependent date and time fields with a time zone
  • “17 May 2024, 15:47:50 GMT” ⇒ locale-dependent date and time fields with a time zone
  • “17 May 2024, 15:47:50 BST” ⇒ locale-dependent date and time fields with a time zone