#[path = "builder.rs"]
pub mod builder;
#[path = "dynamic.rs"]
pub mod enums;
pub use crate::combo::Combo;
use crate::{
options::*,
provider::{neo::*, time_zones::tz, *},
raw::neo::RawOptions,
scaffold::*,
};
use enums::*;
use icu_calendar::{
types::{DayOfMonth, MonthInfo, Weekday, YearInfo},
Date, Iso,
};
use icu_provider::marker::NeverMarker;
use icu_time::{
zone::{TimeZoneVariant, UtcOffset},
Hour, Minute, Nanosecond, Second, Time, TimeZone,
};
#[cfg(doc)]
use icu_time::TimeZoneInfo;
macro_rules! yes_to {
($any:expr, $nonempty:expr) => {
$any
};
}
macro_rules! yes_or {
($fallback:expr, $actual:expr) => {
$actual
};
($fallback:expr,) => {
$fallback
};
}
macro_rules! ternary {
($present:expr, $missing:expr, yes) => {
$present
};
($present:expr, $missing:expr, $any:literal) => {
$present
};
($present:expr, $missing:expr,) => {
$missing
};
}
macro_rules! length_option_helper {
($type:ty, $length:ident) => {
concat!(stringify!($type), "::", stringify!($length), "()")
};
}
macro_rules! impl_composite {
($type:ident, $variant:ident, $enum:ident) => {
impl $type {
#[inline]
pub(crate) fn to_enum(self) -> $enum {
$enum::$type(self)
}
}
impl GetField<CompositeFieldSet> for $type {
#[inline]
fn get_field(&self) -> CompositeFieldSet {
CompositeFieldSet::$variant(self.to_enum())
}
}
};
}
macro_rules! impl_marker_length_constructors {
(
$type:ident,
$(alignment: $alignment_yes:ident,)?
$(year_style: $yearstyle_yes:ident,)?
$(time_precision: $timeprecision_yes:ident,)?
) => {
impl $type {
#[doc = concat!("Creates a ", stringify!($type), " skeleton with the given formatting length.")]
pub const fn with_length(length: Length) -> Self {
Self {
length,
$(
alignment: yes_to!(None, $alignment_yes),
)?
$(
year_style: yes_to!(None, $yearstyle_yes),
)?
$(
time_precision: yes_to!(None, $timeprecision_yes),
)?
}
}
#[doc = concat!("Creates a ", stringify!($type), " skeleton with a long length.")]
pub const fn long() -> Self {
Self::with_length(Length::Long)
}
#[doc = concat!("Creates a ", stringify!($type), " skeleton with a medium length.")]
pub const fn medium() -> Self {
Self::with_length(Length::Medium)
}
#[doc = concat!("Creates a ", stringify!($type), " skeleton with a short length.")]
pub const fn short() -> Self {
Self::with_length(Length::Short)
}
}
};
}
macro_rules! impl_marker_with_options {
(
$(#[$attr:meta])*
$type:ident,
$(sample_length: $sample_length:ident,)?
$(alignment: $alignment_yes:ident,)?
$(year_style: $yearstyle_yes:ident,)?
$(time_precision: $timeprecision_yes:ident,)?
$(length_override: $length_override:ident,)?
) => {
$(#[$attr])*
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct $type {
$(
/// The desired length of the formatted string.
pub length: datetime_marker_helper!(@option/length, $sample_length),
)?
$(
pub alignment: datetime_marker_helper!(@option/alignment, $alignment_yes),
)?
$(
pub year_style: datetime_marker_helper!(@option/yearstyle, $yearstyle_yes),
)?
$(
pub time_precision: datetime_marker_helper!(@option/timeprecision, $timeprecision_yes),
)?
}
impl $type {
pub(crate) fn to_raw_options(self) -> RawOptions {
RawOptions {
length: yes_or!(self.length, $(Length::$length_override)?),
alignment: ternary!(self.alignment, None, $($alignment_yes)?),
year_style: ternary!(self.year_style, None, $($yearstyle_yes)?),
time_precision: ternary!(self.time_precision, None, $($timeprecision_yes)?),
}
}
pub(crate) fn take_from_builder(
options: &mut builder::FieldSetBuilder
) -> Self {
Self {
$(length: yes_to!(options.length.take().unwrap_or_default(), $sample_length),)?
$(alignment: yes_to!(options.alignment.take(), $alignment_yes),)?
$(year_style: yes_to!(options.year_style.take(), $yearstyle_yes),)?
$(time_precision: yes_to!(options.time_precision.take(), $timeprecision_yes),)?
}
}
}
$(
impl $type {
pub const fn with_alignment(mut self, alignment: Alignment) -> Self {
self.alignment = Some(yes_to!(alignment, $alignment_yes));
self
}
}
)?
$(
impl $type {
pub const fn with_year_style(mut self, year_style: YearStyle) -> Self {
self.year_style = Some(yes_to!(year_style, $yearstyle_yes));
self
}
}
)?
$(
impl $type {
pub const fn with_time_precision(mut self, time_precision: TimePrecision) -> Self {
self.time_precision = Some(yes_to!(time_precision, $timeprecision_yes));
self
}
pub fn hm(mut self) -> Self {
self.time_precision = Some(TimePrecision::Minute);
self
}
}
)?
};
}
macro_rules! impl_combo_get_field {
($type:ident, $composite:ident, $enum:ident, $variant:path) => {
impl GetField<CompositeFieldSet> for Combo<$type, $variant> {
#[inline]
fn get_field(&self) -> CompositeFieldSet {
CompositeFieldSet::$composite(Combo::new(self.dt().to_enum(), self.z().to_enum()))
}
}
impl Combo<$type, $variant> {
pub fn into_enums(self) -> Combo<$enum, ZoneFieldSet> {
Combo::new(self.dt().to_enum(), self.z().to_enum())
}
}
};
}
macro_rules! impl_zone_combo_helpers {
(
$type:ident,
$composite:ident,
$enum:ident
) => {
impl $type {
#[inline]
pub fn zone<Z: ZoneMarkers>(self, zone: Z) -> Combo<Self, Z> {
Combo::new(self, zone)
}
}
impl_combo_get_field!($type, $composite, $enum, zone::SpecificLong);
impl_combo_get_field!($type, $composite, $enum, zone::SpecificShort);
impl_combo_get_field!($type, $composite, $enum, zone::LocalizedOffsetLong);
impl_combo_get_field!($type, $composite, $enum, zone::LocalizedOffsetShort);
impl_combo_get_field!($type, $composite, $enum, zone::GenericLong);
impl_combo_get_field!($type, $composite, $enum, zone::GenericShort);
impl_combo_get_field!($type, $composite, $enum, zone::Location);
};
}
macro_rules! impl_date_or_calendar_period_marker {
(
$(#[$attr:meta])*
// The name of the type being created.
$type:ident,
// A plain language description of the field set for documentation.
description = $description:literal,
// Length of the sample string below.
sample_length = $sample_length:ident,
// A sample string. A docs test will be generated!
sample = $sample:literal,
// Whether years can occur.
$(years = $years_yes:ident,)?
// Whether months can occur.
$(months = $months_yes:ident,)?
// Whether weekdays can occur.
$(weekdays = $weekdays_yes:ident,)?
// Whether the input should contain years.
$(input_year = $year_yes:ident,)?
// Whether the input should contain months.
$(input_month = $month_yes:ident,)?
// Whether the input should contain the day of the month.
$(input_day_of_month = $day_of_month_yes:ident,)?
// Whether the input should contain the day of the week.
$(input_day_of_week = $day_of_week_yes:ident,)?
// Whether the input should contain the day of the year.
$(input_day_of_year = $day_of_year_yes:ident,)?
// Whether the input should declare its calendar kind.
$(input_any_calendar_kind = $any_calendar_kind_yes:ident,)?
// Whether the alignment option should be available.
// According to UTS 35, it should be available with years, months, and days.
$(option_alignment = $option_alignment_yes:ident,)?
) => {
impl_marker_with_options!(
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::fieldsets::", stringify!($type), ";")]
#[doc = concat!("let fmt = DateTimeFormatter::<", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($type, $sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[doc = concat!("use icu::datetime::fieldsets::", stringify!($type), ";")]
#[doc = concat!("let fmt = FixedCalendarDateTimeFormatter::<Gregorian, ", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($type, $sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
$(#[$attr])*
$type,
sample_length: $sample_length,
$(alignment: $option_alignment_yes,)?
$(year_style: $year_yes,)?
);
impl_marker_length_constructors!(
$type,
$(alignment: $option_alignment_yes,)?
$(year_style: $year_yes,)?
);
impl UnstableSealed for $type {}
impl DateTimeNamesMarker for $type {
type YearNames = datetime_marker_helper!(@names/year, $($years_yes)?);
type MonthNames = datetime_marker_helper!(@names/month, $($months_yes)?);
type WeekdayNames = datetime_marker_helper!(@names/weekday, $($weekdays_yes)?);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod,);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials,);
type ZoneLocations = datetime_marker_helper!(@names/zone/locations,);
type ZoneLocationsRoot = datetime_marker_helper!(@names/zone/locations_root,);
type ZoneExemplars = datetime_marker_helper!(@names/zone/exemplar,);
type ZoneExemplarsRoot = datetime_marker_helper!(@names/zone/exemplar_root,);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long,);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,);
type ZoneStandardLong = datetime_marker_helper!(@names/zone/standard_long,);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,);
type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,);
}
impl DateInputMarkers for $type {
type YearInput = datetime_marker_helper!(@input/year, $($year_yes)?);
type MonthInput = datetime_marker_helper!(@input/month, $($month_yes)?);
type DayOfMonthInput = datetime_marker_helper!(@input/day_of_month, $($day_of_month_yes)?);
type DayOfYearInput = datetime_marker_helper!(@input/day_of_year, $($day_of_year_yes)?);
type DayOfWeekInput = datetime_marker_helper!(@input/day_of_week, $($day_of_week_yes)?);
}
impl<C: CldrCalendar> TypedDateDataMarkers<C> for $type {
type DateSkeletonPatternsV1 = datetime_marker_helper!(@dates/typed, yes);
type YearNamesV1 = datetime_marker_helper!(@years/typed, $($years_yes)?);
type MonthNamesV1 = datetime_marker_helper!(@months/typed, $($months_yes)?);
type WeekdayNamesV1 = datetime_marker_helper!(@weekdays, $($weekdays_yes)?);
}
impl DateDataMarkers for $type {
type Skel = datetime_marker_helper!(@calmarkers, yes);
type Year = datetime_marker_helper!(@calmarkers, $($years_yes)?);
type Month = datetime_marker_helper!(@calmarkers, $($months_yes)?);
type WeekdayNamesV1 = datetime_marker_helper!(@weekdays, $($weekdays_yes)?);
}
impl DateTimeMarkers for $type {
type D = Self;
type T = ();
type Z = ();
type GluePatternV1 = datetime_marker_helper!(@glue,);
}
};
}
macro_rules! impl_date_marker {
(
$(#[$attr:meta])*
$type:ident,
$type_time:ident,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
sample_time = $sample_time:literal,
$(years = $years_yes:ident,)?
$(months = $months_yes:ident,)?
$(dates = $dates_yes:ident,)?
$(weekdays = $weekdays_yes:ident,)?
$(input_year = $year_yes:ident,)?
$(input_month = $month_yes:ident,)?
$(input_day_of_month = $day_of_month_yes:ident,)?
$(input_day_of_week = $day_of_week_yes:ident,)?
$(input_day_of_year = $day_of_year_yes:ident,)?
$(input_any_calendar_kind = $any_calendar_kind_yes:ident,)?
$(option_alignment = $option_alignment_yes:ident,)?
) => {
impl_date_or_calendar_period_marker!(
$(#[$attr])*
$type,
description = $description,
sample_length = $sample_length,
sample = $sample,
$(years = $years_yes,)?
$(months = $months_yes,)?
$(dates = $dates_yes,)?
$(weekdays = $weekdays_yes,)?
$(input_year = $year_yes,)?
$(input_month = $month_yes,)?
$(input_day_of_month = $day_of_month_yes,)?
$(input_day_of_week = $day_of_week_yes,)?
$(input_day_of_year = $day_of_year_yes,)?
$(input_any_calendar_kind = $any_calendar_kind_yes,)?
$(option_alignment = $option_alignment_yes,)?
);
impl_zone_combo_helpers!($type, DateZone, DateFieldSet);
impl_composite!($type, Date, DateFieldSet);
impl_marker_with_options!(
#[doc = concat!("**“", $sample_time, "**” ⇒ ", $description, " with time")]
#[doc = concat!("use icu::datetime::fieldsets::", stringify!($type_time), ";")]
#[doc = concat!("let fmt = DateTimeFormatter::try_new(")]
#[doc = concat!(" ", length_option_helper!($type_time, $sample_length), ",")]
#[doc = concat!(" \"", $sample_time, "\"")]
#[doc = concat!("use icu::datetime::fieldsets::", stringify!($type_time), ";")]
#[doc = concat!("let fmt = FixedCalendarDateTimeFormatter::try_new(")]
#[doc = concat!(" ", length_option_helper!($type_time, $sample_length), ",")]
#[doc = concat!(" \"", $sample_time, "\"")]
$(#[$attr])*
$type_time,
sample_length: $sample_length,
alignment: yes,
$(year_style: $year_yes,)?
time_precision: yes,
);
impl_marker_length_constructors!(
$type_time,
alignment: yes,
$(year_style: $year_yes,)?
time_precision: yes,
);
impl_zone_combo_helpers!($type_time, DateTimeZone, DateAndTimeFieldSet);
impl UnstableSealed for $type_time {}
impl DateTimeNamesMarker for $type_time {
type YearNames = datetime_marker_helper!(@names/year, $($years_yes)?);
type MonthNames = datetime_marker_helper!(@names/month, $($months_yes)?);
type WeekdayNames = datetime_marker_helper!(@names/weekday, $($weekdays_yes)?);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, yes);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials,);
type ZoneLocations = datetime_marker_helper!(@names/zone/locations,);
type ZoneLocationsRoot = datetime_marker_helper!(@names/zone/locations_root,);
type ZoneExemplars = datetime_marker_helper!(@names/zone/exemplar,);
type ZoneExemplarsRoot = datetime_marker_helper!(@names/zone/exemplar_root,);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long,);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,);
type ZoneStandardLong = datetime_marker_helper!(@names/zone/standard_long,);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,);
type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,);
}
impl DateInputMarkers for $type_time {
type YearInput = datetime_marker_helper!(@input/year, $($year_yes)?);
type MonthInput = datetime_marker_helper!(@input/month, $($month_yes)?);
type DayOfMonthInput = datetime_marker_helper!(@input/day_of_month, $($day_of_month_yes)?);
type DayOfYearInput = datetime_marker_helper!(@input/day_of_year, $($day_of_year_yes)?);
type DayOfWeekInput = datetime_marker_helper!(@input/day_of_week, $($day_of_week_yes)?);
}
impl<C: CldrCalendar> TypedDateDataMarkers<C> for $type_time {
type DateSkeletonPatternsV1 = datetime_marker_helper!(@dates/typed, yes);
type YearNamesV1 = datetime_marker_helper!(@years/typed, $($years_yes)?);
type MonthNamesV1 = datetime_marker_helper!(@months/typed, $($months_yes)?);
type WeekdayNamesV1 = datetime_marker_helper!(@weekdays, $($weekdays_yes)?);
}
impl DateDataMarkers for $type_time {
type Skel = datetime_marker_helper!(@calmarkers, yes);
type Year = datetime_marker_helper!(@calmarkers, $($years_yes)?);
type Month = datetime_marker_helper!(@calmarkers, $($months_yes)?);
type WeekdayNamesV1 = datetime_marker_helper!(@weekdays, $($weekdays_yes)?);
}
impl TimeMarkers for $type_time {
type DayPeriodNamesV1 = datetime_marker_helper!(@dayperiods, yes);
type TimeSkeletonPatternsV1 = datetime_marker_helper!(@times, yes);
type HourInput = datetime_marker_helper!(@input/hour, yes);
type MinuteInput = datetime_marker_helper!(@input/minute, yes);
type SecondInput = datetime_marker_helper!(@input/second, yes);
type NanosecondInput = datetime_marker_helper!(@input/Nanosecond, yes);
}
impl DateTimeMarkers for $type_time {
type D = Self;
type T = Self;
type Z = ();
type GluePatternV1 = datetime_marker_helper!(@glue, yes);
}
impl_composite!($type_time, DateTime, DateAndTimeFieldSet);
impl $type_time {
pub(crate) fn to_date_field_set(self) -> $type {
$type {
length: self.length,
$(alignment: yes_to!(self.alignment, $option_alignment_yes),)?
$(year_style: yes_to!(self.year_style, $years_yes),)?
}
}
}
};
}
macro_rules! impl_calendar_period_marker {
(
$(#[$attr:meta])*
$type:ident,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
$(years = $years_yes:ident,)?
$(months = $months_yes:ident,)?
$(dates = $dates_yes:ident,)?
$(input_year = $year_yes:ident,)?
$(input_month = $month_yes:ident,)?
$(input_any_calendar_kind = $any_calendar_kind_yes:ident,)?
$(option_alignment = $option_alignment_yes:ident,)?
) => {
impl_date_or_calendar_period_marker!(
$(#[$attr])*
$type,
description = $description,
sample_length = $sample_length,
sample = $sample,
$(years = $years_yes,)?
$(months = $months_yes,)?
$(dates = $dates_yes,)?
$(input_year = $year_yes,)?
$(input_month = $month_yes,)?
$(input_any_calendar_kind = $any_calendar_kind_yes,)?
$(option_alignment = $option_alignment_yes,)?
);
impl_composite!($type, CalendarPeriod, CalendarPeriodFieldSet);
};
}
macro_rules! impl_time_marker {
(
$(#[$attr:meta])*
// The name of the type being created.
$type:ident,
// A plain language description of the field set for documentation.
description = $description:literal,
// Length of the sample string below.
sample_length = $sample_length:ident,
// A sample string. A docs test will be generated!
sample = $sample:literal,
// Whether day periods can occur.
$(dayperiods = $dayperiods_yes:ident,)?
// Whether the input should include hours.
$(input_hour = $hour_yes:ident,)?
// Whether the input should contain minutes.
$(input_minute = $minute_yes:ident,)?
// Whether the input should contain seconds.
$(input_second = $second_yes:ident,)?
// Whether the input should contain fractional seconds.
$(input_subsecond = $Nanosecond_yes:ident,)?
) => {
impl_marker_with_options!(
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::fieldsets::", stringify!($type), ";")]
#[doc = concat!("let fmt = NoCalendarFormatter::try_new(")]
#[doc = concat!(" ", length_option_helper!($type, $sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
$(#[$attr])*
$type,
sample_length: $sample_length,
alignment: yes,
time_precision: yes,
);
impl_marker_length_constructors!(
$type,
alignment: yes,
time_precision: yes,
);
impl_zone_combo_helpers!($type, TimeZone, TimeFieldSet);
impl UnstableSealed for $type {}
impl DateTimeNamesMarker for $type {
type YearNames = datetime_marker_helper!(@names/year,);
type MonthNames = datetime_marker_helper!(@names/month,);
type WeekdayNames = datetime_marker_helper!(@names/weekday,);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, $($dayperiods_yes)?);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials,);
type ZoneLocations = datetime_marker_helper!(@names/zone/locations,);
type ZoneLocationsRoot = datetime_marker_helper!(@names/zone/locations_root,);
type ZoneExemplars = datetime_marker_helper!(@names/zone/exemplar,);
type ZoneExemplarsRoot = datetime_marker_helper!(@names/zone/exemplar_root,);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long,);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,);
type ZoneStandardLong = datetime_marker_helper!(@names/zone/standard_long,);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,);
type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,);
}
impl TimeMarkers for $type {
type DayPeriodNamesV1 = datetime_marker_helper!(@dayperiods, $($dayperiods_yes)?);
type TimeSkeletonPatternsV1 = datetime_marker_helper!(@times, yes);
type HourInput = datetime_marker_helper!(@input/hour, $($hour_yes)?);
type MinuteInput = datetime_marker_helper!(@input/minute, $($minute_yes)?);
type SecondInput = datetime_marker_helper!(@input/second, $($second_yes)?);
type NanosecondInput = datetime_marker_helper!(@input/Nanosecond, $($Nanosecond_yes)?);
}
impl DateTimeMarkers for $type {
type D = ();
type T = Self;
type Z = ();
type GluePatternV1 = datetime_marker_helper!(@glue,);
}
impl_composite!($type, Time, TimeFieldSet);
};
}
macro_rules! impl_zone_marker {
(
$(#[$attr:meta])*
// The name of the type being created.
$type:ident,
// A plain language description of the field set for documentation.
description = $description:literal,
// Length of the skeleton if this is the only field.
length_override = $length_override:ident,
// A sample string. A docs test will be generated!
sample = $sample:literal,
// The field symbol and field length.
field = $field:expr,
// The type in ZoneFieldSet for this field set
// Whether zone-essentials should be loaded.
$(zone_essentials = $zone_essentials_yes:ident,)?
// Whether locations names are needed.
$(zone_locations = $zone_locations_yes:ident,)?
// Whether exemplar city names are needed.
$(zone_exemplars = $zone_exemplars_yes:ident,)?
// Whether generic long names are needed.
$(zone_generic_long = $zone_generic_long_yes:ident,)?
// Whether generic short names are needed.
$(zone_generic_short = $zone_generic_short_yes:ident,)?
// Whether standard long names are needed.
$(zone_standard_long = $zone_standard_long_yes:ident,)?
// Whether specific long names are needed.
$(zone_specific_long = $zone_specific_long_yes:ident,)?
// Whether specific short names are needed.
$(zone_specific_short = $zone_specific_short_yes:ident,)?
// Whether metazone periods are needed
$(metazone_periods = $metazone_periods_yes:ident,)?
// Whether to require the TimeZone
$(input_tzid = $tzid_input_yes:ident,)?
// Whether to require the TimeZoneVariant
$(input_variant = $variant_input_yes:ident,)?
// Whether to require the Local Time
$(input_localtime = $localtime_input_yes:ident,)?
) => {
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::fieldsets::zone::", stringify!($type), ";")]
#[doc = concat!(" ", stringify!($type))]
#[doc = concat!(" \"", $sample, "\"")]
$(#[$attr])*
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[allow(clippy::exhaustive_structs)] pub struct $type;
impl UnstableSealed for $type {}
impl DateTimeNamesMarker for $type {
type YearNames = datetime_marker_helper!(@names/year,);
type MonthNames = datetime_marker_helper!(@names/month,);
type WeekdayNames = datetime_marker_helper!(@names/weekday,);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod,);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, $($zone_essentials_yes)?);
type ZoneLocations = datetime_marker_helper!(@names/zone/locations, $($zone_locations_yes)?);
type ZoneLocationsRoot = datetime_marker_helper!(@names/zone/locations_root, $($zone_locations_yes)?);
type ZoneExemplars = datetime_marker_helper!(@names/zone/exemplars, $($zone_exemplars_yes)?);
type ZoneExemplarsRoot = datetime_marker_helper!(@names/zone/exemplars_root, $($zone_exemplars_yes)?);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, $($zone_generic_long_yes)?);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, $($zone_generic_short_yes)?);
type ZoneStandardLong = datetime_marker_helper!(@names/zone/standard_long, $($zone_standard_long_yes)?);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, $($zone_specific_long_yes)?);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, $($zone_specific_short_yes)?);
type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods, $($metazone_periods_yes)?);
}
impl ZoneMarkers for $type {
type TimeZoneIdInput = datetime_marker_helper!(@input/timezone/id, $($tzid_input_yes)?);
type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes);
type TimeZoneVariantInput = datetime_marker_helper!(@input/timezone/variant, $($variant_input_yes)?);
type TimeZoneLocalTimeInput = datetime_marker_helper!(@input/timezone/local_time, $($localtime_input_yes)?);
type EssentialsV1 = datetime_marker_helper!(@data/zone/essentials, $($zone_essentials_yes)?);
type LocationsV1 = datetime_marker_helper!(@data/zone/locations, $($zone_locations_yes)?);
type LocationsRootV1 = datetime_marker_helper!(@data/zone/locations_root, $($zone_locations_yes)?);
type ExemplarCitiesV1 = datetime_marker_helper!(@data/zone/exemplars, $($zone_exemplars_yes)?);
type ExemplarCitiesRootV1 = datetime_marker_helper!(@data/zone/exemplars_root, $($zone_exemplars_yes)?);
type GenericLongV1 = datetime_marker_helper!(@data/zone/generic_long, $($zone_generic_long_yes)?);
type GenericShortV1 = datetime_marker_helper!(@data/zone/generic_short, $($zone_generic_short_yes)?);
type StandardLongV1 = datetime_marker_helper!(@data/zone/standard_long, $($zone_standard_long_yes)?);
type SpecificLongV1 = datetime_marker_helper!(@data/zone/specific_long, $($zone_specific_long_yes)?);
type SpecificShortV1 = datetime_marker_helper!(@data/zone/specific_short, $($zone_specific_short_yes)?);
type MetazonePeriodV1 = datetime_marker_helper!(@data/zone/metazone_periods, $($metazone_periods_yes)?);
}
impl DateTimeMarkers for $type {
type D = ();
type T = ();
type Z = Self;
type GluePatternV1 = datetime_marker_helper!(@glue,);
}
impl_composite!($type, Zone, ZoneFieldSet);
impl $type {
pub(crate) fn to_field(self) -> (fields::TimeZone, fields::FieldLength) {
$field
}
}
};
}
impl_date_marker!(
D,
DT,
description = "day of month (standalone)",
sample_length = short,
sample = "17",
sample_time = "17, 3:47:50 PM",
input_day_of_month = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_date_marker!(
E,
ET,
description = "weekday (standalone)",
sample_length = long,
sample = "Friday",
sample_time = "Friday 3:47:50 PM",
weekdays = yes,
input_day_of_week = yes,
);
impl_date_marker!(
DE,
DET,
description = "day of month and weekday",
sample_length = long,
sample = "17 Friday",
sample_time = "17 Friday, 3:47:50 PM",
weekdays = yes,
input_day_of_month = yes,
input_day_of_week = yes,
option_alignment = yes,
);
impl_date_marker!(
MD,
MDT,
description = "month and day",
sample_length = medium,
sample = "May 17",
sample_time = "May 17, 3:47:50 PM",
months = yes,
input_month = yes,
input_day_of_month = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_date_marker!(
MDE,
MDET,
description = "month, day, and weekday",
sample_length = medium,
sample = "Fri, May 17",
sample_time = "Fri, May 17, 3:47:50 PM",
months = yes,
weekdays = yes,
input_month = yes,
input_day_of_month = yes,
input_day_of_week = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_date_marker!(
YMD,
YMDT,
description = "year, month, and day",
sample_length = short,
sample = "5/17/24",
sample_time = "5/17/24, 3:47:50 PM",
years = yes,
months = yes,
input_year = yes,
input_month = yes,
input_day_of_month = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_date_marker!(
YMDE,
YMDET,
description = "year, month, day, and weekday",
sample_length = short,
sample = "Fri, 5/17/24",
sample_time = "Fri, 5/17/24, 3:47:50 PM",
years = yes,
months = yes,
weekdays = yes,
input_year = yes,
input_month = yes,
input_day_of_month = yes,
input_day_of_week = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_calendar_period_marker!(
Y,
description = "year (standalone)",
sample_length = medium,
sample = "2024",
years = yes,
input_year = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_calendar_period_marker!(
M,
description = "month (standalone)",
sample_length = long,
sample = "May",
months = yes,
input_month = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_calendar_period_marker!(
YM,
description = "year and month",
sample_length = medium,
sample = "May 2024",
years = yes,
months = yes,
input_year = yes,
input_month = yes,
input_any_calendar_kind = yes,
option_alignment = yes,
);
impl_time_marker!(
T,
description = "time (locale-dependent hour cycle)",
sample_length = medium,
sample = "3:47:50 PM",
dayperiods = yes,
input_hour = yes,
input_minute = yes,
input_second = yes,
input_subsecond = yes,
);
pub mod zone {
use super::*;
impl_zone_marker!(
SpecificLong,
description = "time zone in specific non-location format, long length",
length_override = Long,
sample = "Central Daylight Time",
field = (fields::TimeZone::SpecificNonLocation, fields::FieldLength::Four),
zone_essentials = yes,
zone_locations = yes,
zone_standard_long = yes,
zone_specific_long = yes,
metazone_periods = yes,
input_tzid = yes,
input_variant = yes,
input_localtime = yes,
);
impl_zone_marker!(
SpecificShort,
description = "time zone in specific non-location format, short length",
length_override = Short,
sample = "CDT",
field = (fields::TimeZone::SpecificNonLocation, fields::FieldLength::One),
zone_essentials = yes,
zone_specific_short = yes,
metazone_periods = yes,
input_tzid = yes,
input_variant = yes,
input_localtime = yes,
);
impl_zone_marker!(
LocalizedOffsetLong,
description = "UTC offset, long length",
length_override = Long,
sample = "GMT-05:00",
field = (fields::TimeZone::LocalizedOffset, fields::FieldLength::Four),
zone_essentials = yes,
);
impl_zone_marker!(
LocalizedOffsetShort,
description = "UTC offset, short length",
length_override = Short,
sample = "GMT-5",
field = (fields::TimeZone::LocalizedOffset, fields::FieldLength::One),
zone_essentials = yes,
);
impl_zone_marker!(
GenericLong,
description = "time zone in generic non-location format, long length",
length_override = Long,
sample = "Central Time",
field = (fields::TimeZone::GenericNonLocation, fields::FieldLength::Four),
zone_essentials = yes,
zone_locations = yes,
zone_generic_long = yes,
zone_standard_long = yes,
metazone_periods = yes,
input_tzid = yes,
input_localtime = yes,
);
impl_zone_marker!(
GenericShort,
description = "time zone in generic non-location format, short length",
length_override = Short,
sample = "CT",
field = (fields::TimeZone::GenericNonLocation, fields::FieldLength::One),
zone_essentials = yes,
zone_locations = yes,
zone_generic_short = yes,
metazone_periods = yes,
input_tzid = yes,
input_localtime = yes,
);
impl_zone_marker!(
Location,
description = "time zone in location format",
length_override = Long,
sample = "Chicago Time",
field = (fields::TimeZone::Location, fields::FieldLength::Four),
zone_essentials = yes,
zone_locations = yes,
input_tzid = yes,
);
impl_zone_marker!(
ExemplarCity,
description = "time zone in exemplar city format",
length_override = Long,
sample = "Chicago",
field = (fields::TimeZone::Location, fields::FieldLength::Three),
zone_locations = yes,
zone_exemplars = yes,
input_tzid = yes,
);
}
impl_zone_combo_helpers!(DateFieldSet, DateZone, DateFieldSet);
impl_zone_combo_helpers!(TimeFieldSet, TimeZone, TimeFieldSet);
impl_zone_combo_helpers!(DateAndTimeFieldSet, DateTimeZone, DateAndTimeFieldSet);