#[cfg(doc)]
use crate::neo::NeoFormatter;
use core::marker::PhantomData;
use crate::{
format::neo::*,
neo_skeleton::*,
provider::{neo::*, time_zones::tz},
CldrCalendar,
};
use icu_calendar::{
any_calendar::IntoAnyCalendar,
types::{
DayOfMonth, DayOfYearInfo, IsoHour, IsoMinute, IsoSecond, IsoWeekday, MonthInfo,
NanoSecond, YearInfo,
},
AnyCalendar, AnyCalendarKind, AsCalendar, Calendar, Date, DateTime, Ref, Time,
};
use icu_provider::{marker::NeverMarker, prelude::*};
use icu_timezone::{
CustomTimeZone, CustomZonedDateTime, MetazoneId, TimeZoneBcp47Id, UtcOffset, ZoneVariant,
};
#[doc(inline)]
pub use crate::calendar::CalMarkers;
#[doc(inline)]
pub use crate::calendar::FullDataCalMarkers;
#[doc(inline)]
pub use crate::calendar::NoDataCalMarkers;
pub(crate) mod private {
pub trait Sealed {}
}
pub trait ConvertCalendar {
type Converted<'a>: Sized;
fn to_calendar<'a>(&self, calendar: &'a AnyCalendar) -> Self::Converted<'a>;
}
impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> ConvertCalendar for Date<A> {
type Converted<'a> = Date<Ref<'a, AnyCalendar>>;
#[inline]
fn to_calendar<'a>(&self, calendar: &'a AnyCalendar) -> Self::Converted<'a> {
self.to_any().to_calendar(Ref(calendar))
}
}
impl ConvertCalendar for Time {
type Converted<'a> = Time;
#[inline]
fn to_calendar<'a>(&self, _: &'a AnyCalendar) -> Self::Converted<'a> {
*self
}
}
impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> ConvertCalendar for DateTime<A> {
type Converted<'a> = DateTime<Ref<'a, AnyCalendar>>;
#[inline]
fn to_calendar<'a>(&self, calendar: &'a AnyCalendar) -> Self::Converted<'a> {
self.to_any().to_calendar(Ref(calendar))
}
}
impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> ConvertCalendar for CustomZonedDateTime<A> {
type Converted<'a> = CustomZonedDateTime<Ref<'a, AnyCalendar>>;
#[inline]
fn to_calendar<'a>(&self, calendar: &'a AnyCalendar) -> Self::Converted<'a> {
let date = self.date.to_any().to_calendar(Ref(calendar));
CustomZonedDateTime {
date,
time: self.time,
zone: self.zone,
}
}
}
impl ConvertCalendar for CustomTimeZone {
type Converted<'a> = CustomTimeZone;
#[inline]
fn to_calendar<'a>(&self, _: &'a AnyCalendar) -> Self::Converted<'a> {
*self
}
}
pub trait IsAnyCalendarKind {
fn is_any_calendar_kind(&self, any_calendar_kind: AnyCalendarKind) -> bool;
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> IsAnyCalendarKind for Date<A> {
fn is_any_calendar_kind(&self, any_calendar_kind: AnyCalendarKind) -> bool {
self.calendar().any_calendar_kind() == Some(any_calendar_kind)
}
}
impl IsAnyCalendarKind for Time {
fn is_any_calendar_kind(&self, _: AnyCalendarKind) -> bool {
true
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> IsAnyCalendarKind for DateTime<A> {
fn is_any_calendar_kind(&self, any_calendar_kind: AnyCalendarKind) -> bool {
self.date.calendar().any_calendar_kind() == Some(any_calendar_kind)
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> IsAnyCalendarKind for CustomZonedDateTime<A> {
fn is_any_calendar_kind(&self, _: AnyCalendarKind) -> bool {
true
}
}
pub trait IsInCalendar<C> {}
impl<C: Calendar, A: AsCalendar<Calendar = C>> IsInCalendar<C> for Date<A> {}
impl<C> IsInCalendar<C> for Time {}
impl<C: Calendar, A: AsCalendar<Calendar = C>> IsInCalendar<C> for DateTime<A> {}
impl<C: Calendar, A: AsCalendar<Calendar = C>> IsInCalendar<C> for CustomZonedDateTime<A> {}
impl<C> IsInCalendar<C> for CustomTimeZone {}
pub trait NeoGetField<T> {
fn get_field(&self) -> T;
}
impl<T> NeoGetField<T> for T
where
T: Copy,
{
#[inline]
fn get_field(&self) -> T {
*self
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<YearInfo> for Date<A> {
#[inline]
fn get_field(&self) -> YearInfo {
self.year()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<MonthInfo> for Date<A> {
#[inline]
fn get_field(&self) -> MonthInfo {
self.month()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<DayOfMonth> for Date<A> {
#[inline]
fn get_field(&self) -> DayOfMonth {
self.day_of_month()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoWeekday> for Date<A> {
#[inline]
fn get_field(&self) -> IsoWeekday {
self.day_of_week()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<DayOfYearInfo> for Date<A> {
#[inline]
fn get_field(&self) -> DayOfYearInfo {
self.day_of_year_info()
}
}
impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> NeoGetField<AnyCalendarKind> for Date<A> {
#[inline]
fn get_field(&self) -> AnyCalendarKind {
self.calendar().kind()
}
}
impl NeoGetField<IsoHour> for Time {
#[inline]
fn get_field(&self) -> IsoHour {
self.hour
}
}
impl NeoGetField<IsoMinute> for Time {
#[inline]
fn get_field(&self) -> IsoMinute {
self.minute
}
}
impl NeoGetField<IsoSecond> for Time {
#[inline]
fn get_field(&self) -> IsoSecond {
self.second
}
}
impl NeoGetField<NanoSecond> for Time {
#[inline]
fn get_field(&self) -> NanoSecond {
self.nanosecond
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<YearInfo> for DateTime<A> {
#[inline]
fn get_field(&self) -> YearInfo {
self.date.year()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<MonthInfo> for DateTime<A> {
#[inline]
fn get_field(&self) -> MonthInfo {
self.date.month()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<DayOfMonth> for DateTime<A> {
#[inline]
fn get_field(&self) -> DayOfMonth {
self.date.day_of_month()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoWeekday> for DateTime<A> {
#[inline]
fn get_field(&self) -> IsoWeekday {
self.date.day_of_week()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<DayOfYearInfo> for DateTime<A> {
#[inline]
fn get_field(&self) -> DayOfYearInfo {
self.date.day_of_year_info()
}
}
impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> NeoGetField<AnyCalendarKind> for DateTime<A> {
#[inline]
fn get_field(&self) -> AnyCalendarKind {
self.date.calendar().kind()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoHour> for DateTime<A> {
#[inline]
fn get_field(&self) -> IsoHour {
self.time.hour
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoMinute> for DateTime<A> {
#[inline]
fn get_field(&self) -> IsoMinute {
self.time.minute
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoSecond> for DateTime<A> {
#[inline]
fn get_field(&self) -> IsoSecond {
self.time.second
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<NanoSecond> for DateTime<A> {
#[inline]
fn get_field(&self) -> NanoSecond {
self.time.nanosecond
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<YearInfo> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> YearInfo {
self.date.year()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<MonthInfo> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> MonthInfo {
self.date.month()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<DayOfMonth> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> DayOfMonth {
self.date.day_of_month()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoWeekday> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> IsoWeekday {
self.date.day_of_week()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<DayOfYearInfo>
for CustomZonedDateTime<A>
{
#[inline]
fn get_field(&self) -> DayOfYearInfo {
self.date.day_of_year_info()
}
}
impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>> NeoGetField<AnyCalendarKind>
for CustomZonedDateTime<A>
{
#[inline]
fn get_field(&self) -> AnyCalendarKind {
self.date.calendar().kind()
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoHour> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> IsoHour {
self.time.hour
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoMinute> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> IsoMinute {
self.time.minute
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<IsoSecond> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> IsoSecond {
self.time.second
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<NanoSecond> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> NanoSecond {
self.time.nanosecond
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<Option<UtcOffset>>
for CustomZonedDateTime<A>
{
#[inline]
fn get_field(&self) -> Option<UtcOffset> {
self.zone.offset
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<Option<TimeZoneBcp47Id>>
for CustomZonedDateTime<A>
{
#[inline]
fn get_field(&self) -> Option<TimeZoneBcp47Id> {
self.zone.time_zone_id
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<Option<MetazoneId>>
for CustomZonedDateTime<A>
{
#[inline]
fn get_field(&self) -> Option<MetazoneId> {
self.zone.metazone_id
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<Option<ZoneVariant>>
for CustomZonedDateTime<A>
{
#[inline]
fn get_field(&self) -> Option<ZoneVariant> {
self.zone.zone_variant
}
}
impl NeoGetField<Option<UtcOffset>> for CustomTimeZone {
#[inline]
fn get_field(&self) -> Option<UtcOffset> {
self.offset
}
}
impl NeoGetField<Option<TimeZoneBcp47Id>> for CustomTimeZone {
#[inline]
fn get_field(&self) -> Option<TimeZoneBcp47Id> {
self.time_zone_id
}
}
impl NeoGetField<Option<MetazoneId>> for CustomTimeZone {
#[inline]
fn get_field(&self) -> Option<MetazoneId> {
self.metazone_id
}
}
impl NeoGetField<Option<ZoneVariant>> for CustomTimeZone {
#[inline]
fn get_field(&self) -> Option<ZoneVariant> {
self.zone_variant
}
}
#[derive(Debug, Copy, Clone, Default)]
#[allow(clippy::exhaustive_structs)] pub struct NeverField;
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<NeverField> for Date<A> {
#[inline]
fn get_field(&self) -> NeverField {
NeverField
}
}
impl NeoGetField<NeverField> for Time {
#[inline]
fn get_field(&self) -> NeverField {
NeverField
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<NeverField> for DateTime<A> {
#[inline]
fn get_field(&self) -> NeverField {
NeverField
}
}
impl<C: Calendar, A: AsCalendar<Calendar = C>> NeoGetField<NeverField> for CustomZonedDateTime<A> {
#[inline]
fn get_field(&self) -> NeverField {
NeverField
}
}
impl NeoGetField<NeverField> for CustomTimeZone {
#[inline]
fn get_field(&self) -> NeverField {
NeverField
}
}
impl From<NeverField> for Option<YearInfo> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<MonthInfo> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<DayOfMonth> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<IsoWeekday> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<DayOfYearInfo> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<AnyCalendarKind> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<IsoHour> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<IsoMinute> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<IsoSecond> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<NanoSecond> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<UtcOffset> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<TimeZoneBcp47Id> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<MetazoneId> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<ZoneVariant> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<NeoSkeletonLength> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<Alignment> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<EraDisplay> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
impl From<NeverField> for Option<FractionalSecondDigits> {
#[inline]
fn from(_: NeverField) -> Self {
None
}
}
pub trait HasConstComponents {
const COMPONENTS: NeoComponents;
}
pub trait HasConstDateComponents {
const COMPONENTS: NeoDateComponents;
}
pub trait HasConstDayComponents {
const COMPONENTS: NeoDayComponents;
}
pub trait HasConstTimeComponents {
const COMPONENTS: NeoTimeComponents;
}
pub trait HasConstZoneComponent {
const COMPONENT: NeoTimeZoneSkeleton;
}
pub trait DateInputMarkers: private::Sealed {
type YearInput: Into<Option<YearInfo>>;
type MonthInput: Into<Option<MonthInfo>>;
type DayOfMonthInput: Into<Option<DayOfMonth>>;
type DayOfWeekInput: Into<Option<IsoWeekday>>;
type DayOfYearInput: Into<Option<DayOfYearInfo>>;
type AnyCalendarKindInput: Into<Option<AnyCalendarKind>>;
}
pub trait TypedDateDataMarkers<C>: private::Sealed {
type DateSkeletonPatternsV1Marker: DataMarker<DataStruct = PackedSkeletonDataV1<'static>>;
type YearNamesV1Marker: DataMarker<DataStruct = YearNamesV1<'static>>;
type MonthNamesV1Marker: DataMarker<DataStruct = MonthNamesV1<'static>>;
type WeekdayNamesV1Marker: DataMarker<DataStruct = LinearNamesV1<'static>>;
}
pub trait DateDataMarkers: private::Sealed {
type Skel: CalMarkers<SkeletaV1Marker>;
type Year: CalMarkers<YearNamesV1Marker>;
type Month: CalMarkers<MonthNamesV1Marker>;
type WeekdayNamesV1Marker: DataMarker<DataStruct = LinearNamesV1<'static>>;
}
pub trait TimeMarkers: private::Sealed {
type HourInput: Into<Option<IsoHour>>;
type MinuteInput: Into<Option<IsoMinute>>;
type SecondInput: Into<Option<IsoSecond>>;
type NanoSecondInput: Into<Option<NanoSecond>>;
type TimeSkeletonPatternsV1Marker: DataMarker<DataStruct = PackedSkeletonDataV1<'static>>;
type DayPeriodNamesV1Marker: DataMarker<DataStruct = LinearNamesV1<'static>>;
}
pub trait ZoneMarkers: private::Sealed {
type TimeZoneOffsetInput: Into<Option<UtcOffset>>;
type TimeZoneIdInput: Into<Option<TimeZoneBcp47Id>>;
type TimeZoneMetazoneInput: Into<Option<MetazoneId>>;
type TimeZoneVariantInput: Into<Option<ZoneVariant>>;
type EssentialsV1Marker: DataMarker<DataStruct = tz::EssentialsV1<'static>>;
type ExemplarCitiesV1Marker: DataMarker<DataStruct = tz::ExemplarCitiesV1<'static>>;
type GenericLongV1Marker: DataMarker<DataStruct = tz::MzGenericLongV1<'static>>;
type GenericShortV1Marker: DataMarker<DataStruct = tz::MzGenericShortV1<'static>>;
type SpecificLongV1Marker: DataMarker<DataStruct = tz::MzSpecificLongV1<'static>>;
type SpecificShortV1Marker: DataMarker<DataStruct = tz::MzSpecificShortV1<'static>>;
}
pub trait DateTimeMarkers: private::Sealed + DateTimeNamesMarker {
type D;
type T;
type Z;
type LengthOption: Into<Option<NeoSkeletonLength>>;
type AlignmentOption: Into<Option<Alignment>>;
type EraDisplayOption: Into<Option<EraDisplay>>;
type FractionalSecondDigitsOption: Into<Option<FractionalSecondDigits>>;
type GluePatternV1Marker: DataMarker<DataStruct = GluePatternV1<'static>>;
}
pub trait AllInputMarkers<R: DateTimeMarkers>:
NeoGetField<<R::D as DateInputMarkers>::YearInput>
+ NeoGetField<<R::D as DateInputMarkers>::MonthInput>
+ NeoGetField<<R::D as DateInputMarkers>::DayOfMonthInput>
+ NeoGetField<<R::D as DateInputMarkers>::DayOfWeekInput>
+ NeoGetField<<R::D as DateInputMarkers>::DayOfYearInput>
+ NeoGetField<<R::D as DateInputMarkers>::AnyCalendarKindInput>
+ NeoGetField<<R::T as TimeMarkers>::HourInput>
+ NeoGetField<<R::T as TimeMarkers>::MinuteInput>
+ NeoGetField<<R::T as TimeMarkers>::SecondInput>
+ NeoGetField<<R::T as TimeMarkers>::NanoSecondInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneOffsetInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneIdInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneMetazoneInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneVariantInput>
where
R::D: DateInputMarkers,
R::T: TimeMarkers,
R::Z: ZoneMarkers,
{
}
impl<T, R> AllInputMarkers<R> for T
where
R: DateTimeMarkers,
R::D: DateInputMarkers,
R::T: TimeMarkers,
R::Z: ZoneMarkers,
T: NeoGetField<<R::D as DateInputMarkers>::YearInput>
+ NeoGetField<<R::D as DateInputMarkers>::MonthInput>
+ NeoGetField<<R::D as DateInputMarkers>::DayOfMonthInput>
+ NeoGetField<<R::D as DateInputMarkers>::DayOfWeekInput>
+ NeoGetField<<R::D as DateInputMarkers>::DayOfYearInput>
+ NeoGetField<<R::D as DateInputMarkers>::AnyCalendarKindInput>
+ NeoGetField<<R::T as TimeMarkers>::HourInput>
+ NeoGetField<<R::T as TimeMarkers>::MinuteInput>
+ NeoGetField<<R::T as TimeMarkers>::SecondInput>
+ NeoGetField<<R::T as TimeMarkers>::NanoSecondInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneOffsetInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneIdInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneMetazoneInput>
+ NeoGetField<<R::Z as ZoneMarkers>::TimeZoneVariantInput>,
{
}
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum NeoNeverMarker {}
impl private::Sealed for NeoNeverMarker {}
impl DateInputMarkers for NeoNeverMarker {
type YearInput = NeverField;
type MonthInput = NeverField;
type DayOfMonthInput = NeverField;
type DayOfWeekInput = NeverField;
type DayOfYearInput = NeverField;
type AnyCalendarKindInput = NeverField;
}
impl<C> TypedDateDataMarkers<C> for NeoNeverMarker {
type DateSkeletonPatternsV1Marker = NeverMarker<PackedSkeletonDataV1<'static>>;
type YearNamesV1Marker = NeverMarker<YearNamesV1<'static>>;
type MonthNamesV1Marker = NeverMarker<MonthNamesV1<'static>>;
type WeekdayNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
}
impl DateDataMarkers for NeoNeverMarker {
type Skel = NoDataCalMarkers;
type Year = NoDataCalMarkers;
type Month = NoDataCalMarkers;
type WeekdayNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
}
impl TimeMarkers for NeoNeverMarker {
type HourInput = NeverField;
type MinuteInput = NeverField;
type SecondInput = NeverField;
type NanoSecondInput = NeverField;
type TimeSkeletonPatternsV1Marker = NeverMarker<PackedSkeletonDataV1<'static>>;
type DayPeriodNamesV1Marker = NeverMarker<LinearNamesV1<'static>>;
}
impl ZoneMarkers for NeoNeverMarker {
type TimeZoneOffsetInput = NeverField;
type TimeZoneIdInput = NeverField;
type TimeZoneMetazoneInput = NeverField;
type TimeZoneVariantInput = NeverField;
type EssentialsV1Marker = NeverMarker<tz::EssentialsV1<'static>>;
type ExemplarCitiesV1Marker = NeverMarker<tz::ExemplarCitiesV1<'static>>;
type GenericLongV1Marker = NeverMarker<tz::MzGenericLongV1<'static>>;
type GenericShortV1Marker = NeverMarker<tz::MzGenericShortV1<'static>>;
type SpecificLongV1Marker = NeverMarker<tz::MzSpecificLongV1<'static>>;
type SpecificShortV1Marker = NeverMarker<tz::MzSpecificShortV1<'static>>;
}
#[derive(Debug)]
pub struct DateTimeCombo<D, T, Z> {
_d: PhantomData<D>,
_t: PhantomData<T>,
_z: PhantomData<Z>,
}
impl<D, T, Z> private::Sealed for DateTimeCombo<D, T, Z> {}
impl<D> DateTimeNamesMarker for DateTimeCombo<D, NeoNeverMarker, NeoNeverMarker>
where
D: DateTimeNamesMarker,
{
type YearNames = D::YearNames;
type MonthNames = D::MonthNames;
type WeekdayNames = D::WeekdayNames;
type DayPeriodNames = NeverMarker<()>;
type ZoneEssentials = NeverMarker<()>;
type ZoneExemplarCities = NeverMarker<()>;
type ZoneGenericLong = NeverMarker<()>;
type ZoneGenericShort = NeverMarker<()>;
type ZoneSpecificLong = NeverMarker<()>;
type ZoneSpecificShort = NeverMarker<()>;
}
impl<D> HasConstComponents for DateTimeCombo<D, NeoNeverMarker, NeoNeverMarker>
where
D: HasConstDateComponents,
{
const COMPONENTS: NeoComponents = NeoComponents::Date(D::COMPONENTS);
}
impl<D> DateTimeMarkers for DateTimeCombo<D, NeoNeverMarker, NeoNeverMarker>
where
D: DateTimeMarkers,
{
type D = D;
type T = NeoNeverMarker;
type Z = NeoNeverMarker;
type LengthOption = NeoSkeletonLength; type AlignmentOption = D::AlignmentOption;
type EraDisplayOption = D::EraDisplayOption;
type FractionalSecondDigitsOption = NeverField;
type GluePatternV1Marker = NeverMarker<GluePatternV1<'static>>;
}
impl<T> DateTimeNamesMarker for DateTimeCombo<NeoNeverMarker, T, NeoNeverMarker>
where
T: DateTimeNamesMarker,
{
type YearNames = NeverMarker<()>;
type MonthNames = NeverMarker<()>;
type WeekdayNames = NeverMarker<()>;
type DayPeriodNames = T::DayPeriodNames;
type ZoneEssentials = NeverMarker<()>;
type ZoneExemplarCities = NeverMarker<()>;
type ZoneGenericLong = NeverMarker<()>;
type ZoneGenericShort = NeverMarker<()>;
type ZoneSpecificLong = NeverMarker<()>;
type ZoneSpecificShort = NeverMarker<()>;
}
impl<T> HasConstComponents for DateTimeCombo<NeoNeverMarker, T, NeoNeverMarker>
where
T: HasConstTimeComponents,
{
const COMPONENTS: NeoComponents = NeoComponents::Time(T::COMPONENTS);
}
impl<T> DateTimeMarkers for DateTimeCombo<NeoNeverMarker, T, NeoNeverMarker>
where
T: DateTimeMarkers,
{
type D = NeoNeverMarker;
type T = T;
type Z = NeoNeverMarker;
type LengthOption = NeoSkeletonLength; type AlignmentOption = Option<Alignment>; type EraDisplayOption = NeverField; type FractionalSecondDigitsOption = T::FractionalSecondDigitsOption;
type GluePatternV1Marker = NeverMarker<GluePatternV1<'static>>;
}
impl<Z> DateTimeNamesMarker for DateTimeCombo<NeoNeverMarker, NeoNeverMarker, Z>
where
Z: DateTimeNamesMarker,
{
type YearNames = NeverMarker<()>;
type MonthNames = NeverMarker<()>;
type WeekdayNames = NeverMarker<()>;
type DayPeriodNames = NeverMarker<()>;
type ZoneEssentials = Z::ZoneEssentials;
type ZoneExemplarCities = Z::ZoneExemplarCities;
type ZoneGenericLong = Z::ZoneGenericLong;
type ZoneGenericShort = Z::ZoneGenericShort;
type ZoneSpecificLong = Z::ZoneSpecificLong;
type ZoneSpecificShort = Z::ZoneSpecificShort;
}
impl<Z> HasConstComponents for DateTimeCombo<NeoNeverMarker, NeoNeverMarker, Z>
where
Z: HasConstZoneComponent,
{
const COMPONENTS: NeoComponents = NeoComponents::Zone(Z::COMPONENT);
}
impl<Z> DateTimeMarkers for DateTimeCombo<NeoNeverMarker, NeoNeverMarker, Z>
where
Z: DateTimeMarkers,
{
type D = NeoNeverMarker;
type T = NeoNeverMarker;
type Z = Z;
type LengthOption = Z::LengthOption; type AlignmentOption = Z::AlignmentOption; type EraDisplayOption = NeverField; type FractionalSecondDigitsOption = NeverField;
type GluePatternV1Marker = GluePatternV1Marker;
}
impl<D, T> DateTimeNamesMarker for DateTimeCombo<D, T, NeoNeverMarker>
where
D: DateTimeNamesMarker,
T: DateTimeNamesMarker,
{
type YearNames = D::YearNames;
type MonthNames = D::MonthNames;
type WeekdayNames = D::WeekdayNames;
type DayPeriodNames = T::DayPeriodNames;
type ZoneEssentials = NeverMarker<()>;
type ZoneExemplarCities = NeverMarker<()>;
type ZoneGenericLong = NeverMarker<()>;
type ZoneGenericShort = NeverMarker<()>;
type ZoneSpecificLong = NeverMarker<()>;
type ZoneSpecificShort = NeverMarker<()>;
}
impl<D, T> HasConstComponents for DateTimeCombo<D, T, NeoNeverMarker>
where
D: HasConstDayComponents,
T: HasConstTimeComponents,
{
const COMPONENTS: NeoComponents = NeoComponents::DateTime(D::COMPONENTS, T::COMPONENTS);
}
impl<D, T> DateTimeMarkers for DateTimeCombo<D, T, NeoNeverMarker>
where
D: DateTimeMarkers,
T: DateTimeMarkers,
{
type D = D;
type T = T;
type Z = NeoNeverMarker;
type LengthOption = NeoSkeletonLength; type AlignmentOption = Option<Alignment>; type EraDisplayOption = D::EraDisplayOption;
type FractionalSecondDigitsOption = T::FractionalSecondDigitsOption;
type GluePatternV1Marker = GluePatternV1Marker;
}
impl<D, T, Z> DateTimeNamesMarker for DateTimeCombo<D, T, Z>
where
D: DateTimeNamesMarker,
T: DateTimeNamesMarker,
Z: DateTimeNamesMarker,
{
type YearNames = D::YearNames;
type MonthNames = D::MonthNames;
type WeekdayNames = D::WeekdayNames;
type DayPeriodNames = T::DayPeriodNames;
type ZoneEssentials = Z::ZoneEssentials;
type ZoneExemplarCities = Z::ZoneExemplarCities;
type ZoneGenericLong = Z::ZoneGenericLong;
type ZoneGenericShort = Z::ZoneGenericShort;
type ZoneSpecificLong = Z::ZoneSpecificLong;
type ZoneSpecificShort = Z::ZoneSpecificShort;
}
impl<D, T, Z> HasConstComponents for DateTimeCombo<D, T, Z>
where
D: HasConstDayComponents,
T: HasConstTimeComponents,
Z: HasConstZoneComponent,
{
const COMPONENTS: NeoComponents =
NeoComponents::DateTimeZone(D::COMPONENTS, T::COMPONENTS, Z::COMPONENT);
}
impl<D, T, Z> DateTimeMarkers for DateTimeCombo<D, T, Z>
where
D: DateTimeMarkers,
T: DateTimeMarkers,
Z: DateTimeMarkers,
{
type D = D;
type T = T;
type Z = Z;
type LengthOption = NeoSkeletonLength; type AlignmentOption = Option<Alignment>; type EraDisplayOption = D::EraDisplayOption;
type FractionalSecondDigitsOption = T::FractionalSecondDigitsOption;
type GluePatternV1Marker = GluePatternV1Marker;
}
macro_rules! datetime_marker_helper {
(@years/typed, yes) => {
C::YearNamesV1Marker
};
(@years/typed, no) => {
NeverMarker<YearNamesV1<'static>>
};
(@months/typed, yes) => {
C::MonthNamesV1Marker
};
(@months/typed, no) => {
NeverMarker<MonthNamesV1<'static>>
};
(@dates/typed, yes) => {
C::SkeletaV1Marker
};
(@dates/typed, no) => {
NeverMarker<PackedSkeletonDataV1<'static>>
};
(@calmarkers, yes) => {
FullDataCalMarkers
};
(@calmarkers, no) => {
NoDataCalMarkers
};
(@weekdays, yes) => {
WeekdayNamesV1Marker
};
(@weekdays, no) => {
NeverMarker<LinearNamesV1<'static>>
};
(@dayperiods, yes) => {
DayPeriodNamesV1Marker
};
(@dayperiods, no) => {
NeverMarker<LinearNamesV1<'static>>
};
(@times, yes) => {
TimeNeoSkeletonPatternsV1Marker
};
(@times, no) => {
NeverMarker<PackedSkeletonDataV1<'static>>
};
(@glue, yes) => {
GluePatternV1Marker
};
(@glue, no) => {
NeverMarker<GluePatternV1<'static>>
};
(@option/eradisplay, yes) => {
Option<EraDisplay>
};
(@option/alignment, yes) => {
Option<Alignment>
};
(@option/alignment, no, no) => {
NeverField
};
(@option/alignment, $any0:ident, $any1:ident) => {
Option<Alignment>
};
(@option/fractionalsecondigits, yes) => {
Option<FractionalSecondDigits>
};
(@option/$any:ident, no) => {
NeverField
};
(@option/length, $any:ident) => {
NeoSkeletonLength
};
(@input/year, yes) => {
YearInfo
};
(@input/month, yes) => {
MonthInfo
};
(@input/day_of_month, yes) => {
DayOfMonth
};
(@input/day_of_week, yes) => {
IsoWeekday
};
(@input/day_of_year, yes) => {
DayOfYearInfo
};
(@input/any_calendar_kind, yes) => {
AnyCalendarKind
};
(@input/hour, yes) => {
IsoHour
};
(@input/minute, yes) => {
IsoMinute
};
(@input/second, yes) => {
IsoSecond
};
(@input/nanosecond, yes) => {
NanoSecond
};
(@input/timezone/offset, yes) => {
Option<UtcOffset>
};
(@input/timezone/id, yes) => {
Option<TimeZoneBcp47Id>
};
(@input/timezone/metazone, yes) => {
Option<MetazoneId>
};
(@input/timezone/variant, yes) => {
Option<ZoneVariant>
};
(@input/$any:ident, no) => {
NeverField
};
(@data/zone/essentials, yes) => {
tz::EssentialsV1Marker
};
(@data/zone/exemplar_cities, yes) => {
tz::ExemplarCitiesV1Marker
};
(@data/zone/generic_long, yes) => {
tz::MzGenericLongV1Marker
};
(@data/zone/generic_short, yes) => {
tz::MzGenericShortV1Marker
};
(@data/zone/specific_long, yes) => {
tz::MzSpecificLongV1Marker
};
(@data/zone/specific_short, yes) => {
tz::MzSpecificShortV1Marker
};
(@data/zone/essentials, no) => {
NeverMarker<tz::EssentialsV1<'static>>
};
(@data/zone/exemplar_cities, no) => {
NeverMarker<tz::ExemplarCitiesV1<'static>>
};
(@data/zone/generic_long, no) => {
NeverMarker<tz::MzGenericLongV1<'static>>
};
(@data/zone/generic_short, no) => {
NeverMarker<tz::MzGenericShortV1<'static>>
};
(@data/zone/specific_long, no) => {
NeverMarker<tz::MzSpecificLongV1<'static>>
};
(@data/zone/specific_short, no) => {
NeverMarker<tz::MzSpecificShortV1<'static>>
};
(@names/year, yes) => {
YearNamesV1Marker
};
(@names/month, yes) => {
MonthNamesV1Marker
};
(@names/weekday, yes) => {
WeekdayNamesV1Marker
};
(@names/dayperiod, yes) => {
DayPeriodNamesV1Marker
};
(@names/zone/essentials, yes) => {
tz::EssentialsV1Marker
};
(@names/zone/exemplar_cities, yes) => {
tz::ExemplarCitiesV1Marker
};
(@names/zone/generic_long, yes) => {
tz::MzGenericLongV1Marker
};
(@names/zone/generic_short, yes) => {
tz::MzGenericShortV1Marker
};
(@names/zone/specific_long, yes) => {
tz::MzSpecificLongV1Marker
};
(@names/zone/specific_short, yes) => {
tz::MzSpecificShortV1Marker
};
(@names/$any:ident, no) => {
NeverMarker<()>
};
(@names/zone/$any:ident, no) => {
NeverMarker<()>
};
}
macro_rules! length_option_helper {
(no) => {
stringify!(Default::default())
};
($length:ident) => {
concat!("NeoSkeletonLength::", stringify!($length), ".into()")
};
}
macro_rules! impl_date_marker {
(
$type:ident,
$components:expr,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
years = $years_yesno:ident,
months = $months_yesno:ident,
dates = $dates_yesno:ident,
weekdays = $weekdays_yesno:ident,
input_year = $year_yesno:ident,
input_month = $month_yesno:ident,
input_day_of_month = $day_of_month_yesno:ident,
input_day_of_week = $day_of_week_yesno:ident,
input_day_of_year = $day_of_year_yesno:ident,
input_any_calendar_kind = $any_calendar_kind_yesno:ident,
) => {
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = TypedNeoFormatter::<Gregorian, ", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum $type {}
impl private::Sealed for $type {}
impl DateTimeNamesMarker for $type {
type YearNames = datetime_marker_helper!(@names/year, $years_yesno);
type MonthNames = datetime_marker_helper!(@names/month, $months_yesno);
type WeekdayNames = datetime_marker_helper!(@names/weekday, $weekdays_yesno);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, no);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, no);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, no);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, no);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, no);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, no);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, no);
}
impl HasConstDateComponents for $type {
const COMPONENTS: NeoDateComponents = $components;
}
impl DateInputMarkers for $type {
type YearInput = datetime_marker_helper!(@input/year, $year_yesno);
type MonthInput = datetime_marker_helper!(@input/month, $month_yesno);
type DayOfMonthInput = datetime_marker_helper!(@input/day_of_month, $day_of_month_yesno);
type DayOfWeekInput = datetime_marker_helper!(@input/day_of_week, $day_of_week_yesno);
type DayOfYearInput = datetime_marker_helper!(@input/day_of_year, $day_of_year_yesno);
type AnyCalendarKindInput = datetime_marker_helper!(@input/any_calendar_kind, $any_calendar_kind_yesno);
}
impl<C: CldrCalendar> TypedDateDataMarkers<C> for $type {
type DateSkeletonPatternsV1Marker = datetime_marker_helper!(@dates/typed, $dates_yesno);
type YearNamesV1Marker = datetime_marker_helper!(@years/typed, $years_yesno);
type MonthNamesV1Marker = datetime_marker_helper!(@months/typed, $months_yesno);
type WeekdayNamesV1Marker = datetime_marker_helper!(@weekdays, $weekdays_yesno);
}
impl DateDataMarkers for $type {
type Skel = datetime_marker_helper!(@calmarkers, $dates_yesno);
type Year = datetime_marker_helper!(@calmarkers, $years_yesno);
type Month = datetime_marker_helper!(@calmarkers, $months_yesno);
type WeekdayNamesV1Marker = datetime_marker_helper!(@weekdays, $weekdays_yesno);
}
impl DateTimeMarkers for $type {
type D = Self;
type T = NeoNeverMarker;
type Z = NeoNeverMarker;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, $months_yesno, $dates_yesno);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, $year_yesno);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, no);
type GluePatternV1Marker = datetime_marker_helper!(@glue, no);
}
impl HasConstComponents for $type {
const COMPONENTS: NeoComponents = NeoComponents::Date($components);
}
};
}
macro_rules! impl_day_marker {
(
$type:ident,
$components:expr,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
years = $years_yesno:ident,
months = $months_yesno:ident,
dates = $dates_yesno:ident,
weekdays = $weekdays_yesno:ident,
input_year = $year_yesno:ident,
input_month = $month_yesno:ident,
input_day_of_month = $day_of_month_yesno:ident,
input_day_of_week = $day_of_week_yesno:ident,
input_day_of_year = $day_of_year_yesno:ident,
input_any_calendar_kind = $any_calendar_kind_yesno:ident,
) => {
impl_date_marker!(
$type,
NeoDateComponents::Day($components),
description = $description,
sample_length = $sample_length,
sample = $sample,
years = $years_yesno,
months = $months_yesno,
dates = $dates_yesno,
weekdays = $weekdays_yesno,
input_year = $year_yesno,
input_month = $month_yesno,
input_day_of_month = $day_of_month_yesno,
input_day_of_week = $day_of_week_yesno,
input_day_of_year = $day_of_year_yesno,
input_any_calendar_kind = $any_calendar_kind_yesno,
);
impl HasConstDayComponents for $type {
const COMPONENTS: NeoDayComponents = $components;
}
};
}
macro_rules! impl_time_marker {
(
$type:ident,
$components:expr,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
dayperiods = $dayperiods_yesno:ident,
times = $times_yesno:ident,
input_hour = $hour_yesno:ident,
input_minute = $minute_yesno:ident,
input_second = $second_yesno:ident,
input_nanosecond = $nanosecond_yesno:ident,
) => {
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = TypedNeoFormatter::<Gregorian, ", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum $type {}
impl private::Sealed for $type {}
impl DateTimeNamesMarker for $type {
type YearNames = datetime_marker_helper!(@names/year, no);
type MonthNames = datetime_marker_helper!(@names/month, no);
type WeekdayNames = datetime_marker_helper!(@names/weekday, no);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, $dayperiods_yesno);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, no);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, no);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, no);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, no);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, no);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, no);
}
impl HasConstTimeComponents for $type {
const COMPONENTS: NeoTimeComponents = $components;
}
impl TimeMarkers for $type {
type DayPeriodNamesV1Marker = datetime_marker_helper!(@dayperiods, $dayperiods_yesno);
type TimeSkeletonPatternsV1Marker = datetime_marker_helper!(@times, $times_yesno);
type HourInput = datetime_marker_helper!(@input/hour, $hour_yesno);
type MinuteInput = datetime_marker_helper!(@input/minute, $minute_yesno);
type SecondInput = datetime_marker_helper!(@input/second, $second_yesno);
type NanoSecondInput = datetime_marker_helper!(@input/nanosecond, $nanosecond_yesno);
}
impl DateTimeMarkers for $type {
type D = NeoNeverMarker;
type T = Self;
type Z = NeoNeverMarker;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, yes);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, no);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, $nanosecond_yesno);
type GluePatternV1Marker = datetime_marker_helper!(@glue, no);
}
impl HasConstComponents for $type {
const COMPONENTS: NeoComponents = NeoComponents::Time($components);
}
};
}
macro_rules! impl_zone_marker {
(
$(#[$attr:meta])*
$type:ident,
$components:expr,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
zone_essentials = $zone_essentials_yesno:ident,
zone_exemplar_cities = $zone_exemplar_cities_yesno:ident,
zone_generic_long = $zone_generic_long_yesno:ident,
zone_generic_short = $zone_generic_short_yesno:ident,
zone_specific_long = $zone_specific_long_yesno:ident,
zone_specific_short = $zone_specific_short_yesno:ident,
) => {
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = TypedNeoFormatter::<Gregorian, ", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
$(#[$attr])*
#[derive(Debug)]
#[allow(clippy::exhaustive_enums)] pub enum $type {}
impl private::Sealed for $type {}
impl DateTimeNamesMarker for $type {
type YearNames = datetime_marker_helper!(@names/year, no);
type MonthNames = datetime_marker_helper!(@names/month, no);
type WeekdayNames = datetime_marker_helper!(@names/weekday, no);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, no);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, $zone_essentials_yesno);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, $zone_exemplar_cities_yesno);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, $zone_generic_long_yesno);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, $zone_generic_short_yesno);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, $zone_specific_long_yesno);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, $zone_specific_short_yesno);
}
impl HasConstZoneComponent for $type {
const COMPONENT: NeoTimeZoneSkeleton = $components;
}
impl ZoneMarkers for $type {
type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes);
type TimeZoneIdInput = datetime_marker_helper!(@input/timezone/id, yes);
type TimeZoneMetazoneInput = datetime_marker_helper!(@input/timezone/metazone, yes);
type TimeZoneVariantInput = datetime_marker_helper!(@input/timezone/variant, yes);
type EssentialsV1Marker = datetime_marker_helper!(@data/zone/essentials, $zone_essentials_yesno);
type ExemplarCitiesV1Marker = datetime_marker_helper!(@data/zone/exemplar_cities, $zone_exemplar_cities_yesno);
type GenericLongV1Marker = datetime_marker_helper!(@data/zone/generic_long, $zone_generic_long_yesno);
type GenericShortV1Marker = datetime_marker_helper!(@data/zone/generic_short, $zone_generic_short_yesno);
type SpecificLongV1Marker = datetime_marker_helper!(@data/zone/specific_long, $zone_specific_long_yesno);
type SpecificShortV1Marker = datetime_marker_helper!(@data/zone/specific_short, $zone_specific_short_yesno);
}
impl DateTimeMarkers for $type {
type D = NeoNeverMarker;
type T = NeoNeverMarker;
type Z = Self;
type LengthOption = datetime_marker_helper!(@option/length, $sample_length);
type AlignmentOption = datetime_marker_helper!(@option/alignment, no);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, no);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, no);
type GluePatternV1Marker = datetime_marker_helper!(@glue, no);
}
impl HasConstComponents for $type {
const COMPONENTS: NeoComponents = NeoComponents::Zone($components);
}
};
}
macro_rules! impl_datetime_marker {
(
$type:ident,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
date = $date:path,
time = $time:path,
) => {
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = TypedNeoFormatter::<Gregorian, ", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
pub type $type = DateTimeCombo<$date, $time, NeoNeverMarker>;
}
}
macro_rules! impl_zoneddatetime_marker {
(
$type:ident,
description = $description:literal,
sample_length = $sample_length:ident,
sample = $sample:literal,
date = $date:path,
time = $time:path,
zone = $zone:path,
) => {
#[doc = concat!("**“", $sample, "**” ⇒ ", $description)]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
#[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")]
#[doc = concat!("let fmt = TypedNeoFormatter::<Gregorian, ", stringify!($type), ">::try_new(")]
#[doc = concat!(" ", length_option_helper!($sample_length), ",")]
#[doc = concat!(" \"", $sample, "\"")]
pub type $type = DateTimeCombo<$date, $time, $zone>;
}
}
impl_day_marker!(
NeoYearMonthDayMarker,
NeoDayComponents::YearMonthDay,
description = "year, month, and day (year might be abbreviated)",
sample_length = Short,
sample = "5/17/24",
years = yes,
months = yes,
dates = yes,
weekdays = yes,
input_year = yes,
input_month = yes,
input_day_of_month = yes,
input_day_of_week = no,
input_day_of_year = no,
input_any_calendar_kind = yes,
);
impl_day_marker!(
NeoEraYearMonthDayMarker,
NeoDayComponents::EraYearMonthDay,
description = "year, month, and day (year always with full precision)",
sample_length = Medium,
sample = "May 17, 2024",
years = yes,
months = yes,
dates = yes,
weekdays = no,
input_year = yes,
input_month = yes,
input_day_of_month = yes,
input_day_of_week = no,
input_day_of_year = no,
input_any_calendar_kind = yes,
);
impl_day_marker!(
NeoAutoDateMarker,
NeoDayComponents::Auto,
description = "locale-dependent date fields",
sample_length = Medium,
sample = "May 17, 2024",
years = yes,
months = yes,
dates = yes,
weekdays = yes,
input_year = yes,
input_month = yes,
input_day_of_month = yes,
input_day_of_week = yes,
input_day_of_year = no,
input_any_calendar_kind = yes,
);
impl_time_marker!(
NeoHourMinuteMarker,
NeoTimeComponents::HourMinute,
description = "hour and minute (locale-dependent hour cycle)",
sample_length = Medium,
sample = "3:47 PM",
dayperiods = yes,
times = yes,
input_hour = yes,
input_minute = yes,
input_second = no,
input_nanosecond = no,
);
impl_time_marker!(
NeoHourMinuteSecondMarker,
NeoTimeComponents::HourMinuteSecond,
description = "hour, minute, and second (locale-dependent hour cycle)",
sample_length = Medium,
sample = "3:47:50 PM",
dayperiods = yes,
times = yes,
input_hour = yes,
input_minute = yes,
input_second = yes,
input_nanosecond = yes,
);
impl_time_marker!(
NeoAutoTimeMarker,
NeoTimeComponents::Auto,
description = "locale-dependent time fields",
sample_length = Medium,
sample = "3:47:50 PM",
dayperiods = yes,
times = yes,
input_hour = yes,
input_minute = yes,
input_second = yes,
input_nanosecond = yes,
);
impl_datetime_marker!(
NeoAutoDateTimeMarker,
description = "locale-dependent date and time fields",
sample_length = Medium,
sample = "May 17, 2024, 3:47:50 PM",
date = NeoAutoDateMarker,
time = NeoAutoTimeMarker,
);
impl_datetime_marker!(
NeoYearMonthDayHourMinuteMarker,
description = "locale-dependent date and time fields",
sample_length = Medium,
sample = "May 17, 2024, 3:47 PM",
date = NeoYearMonthDayMarker,
time = NeoHourMinuteMarker,
);
impl_date_marker!(
NeoYearMonthMarker,
NeoDateComponents::YearMonth,
description = "year and month (era elided when possible)",
sample_length = Medium,
sample = "May 2024",
years = yes,
months = yes,
dates = yes,
weekdays = no,
input_year = yes,
input_month = yes,
input_day_of_month = no,
input_day_of_week = no,
input_day_of_year = no,
input_any_calendar_kind = yes,
);
impl_zone_marker!(
NeoTimeZoneSpecificMarker,
NeoTimeZoneSkeleton::specific(),
description = "specific time zone with inherited length, or raw offset if unavailable",
sample_length = Medium,
sample = "CDT",
zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = yes,
);
impl_zone_marker!(
NeoTimeZoneSpecificShortMarker,
NeoTimeZoneSkeleton::specific_short(),
description = "specific time zone with a shorter length, or raw offset if unavailable",
sample_length = no,
sample = "CDT",
zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = yes,
);
impl_zone_marker!(
NeoTimeZoneSpecificLongMarker,
NeoTimeZoneSkeleton::specific_long(),
description = "specific time zone with a longer length, or raw offset if unavailable",
sample_length = no,
sample = "Central Daylight Time",
zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = yes,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneOffsetMarker,
NeoTimeZoneSkeleton::offset(),
description = "UTC offset with inherited length",
sample_length = Medium,
sample = "GMT-05:00", zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneOffsetShortMarker,
NeoTimeZoneSkeleton::offset_short(),
description = "UTC offset with a shorter length",
sample_length = no,
sample = "GMT-05:00", zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneOffsetLongMarker,
NeoTimeZoneSkeleton::offset_long(),
description = "UTC offset with a longer length",
sample_length = no,
sample = "GMT-05:00",
zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneGenericMarker,
NeoTimeZoneSkeleton::generic(),
description = "generic time zone with inherited length, or location if unavailable",
sample_length = Medium,
sample = "CT",
zone_essentials = yes,
zone_exemplar_cities = yes,
zone_generic_long = no,
zone_generic_short = yes,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneGenericShortMarker,
NeoTimeZoneSkeleton::generic_short(),
description = "generic time zone with a shorter length, or location if unavailable",
sample_length = no,
sample = "CT",
zone_essentials = yes,
zone_exemplar_cities = yes,
zone_generic_long = no,
zone_generic_short = yes,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneGenericLongMarker,
NeoTimeZoneSkeleton::generic_long(),
description = "generic time zone with a longer length, or location if unavailable",
sample_length = no,
sample = "Central Time",
zone_essentials = yes,
zone_exemplar_cities = yes,
zone_generic_long = yes,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zone_marker!(
NeoTimeZoneLocationMarker,
NeoTimeZoneSkeleton::location(),
description = "location time zone",
sample_length = no,
sample = "Chicago Time",
zone_essentials = yes,
zone_exemplar_cities = yes,
zone_generic_long = no,
zone_generic_short = no,
zone_specific_long = no,
zone_specific_short = no,
);
impl_zoneddatetime_marker!(
NeoYearMonthDayHourMinuteSecondTimeZoneGenericShortMarker,
description = "locale-dependent date and time fields with a time zone",
sample_length = Medium,
sample = "May 17, 2024, 3:47:50 PM GMT",
date = NeoAutoDateMarker,
time = NeoAutoTimeMarker,
zone = NeoTimeZoneGenericShortMarker,
);
pub trait IsRuntimeComponents: private::Sealed + Into<NeoComponents> {}
impl private::Sealed for NeoDateComponents {}
impl IsRuntimeComponents for NeoDateComponents {}
impl DateTimeNamesMarker for NeoDateComponents {
type YearNames = datetime_marker_helper!(@names/year, yes);
type MonthNames = datetime_marker_helper!(@names/month, yes);
type WeekdayNames = datetime_marker_helper!(@names/weekday, yes);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, no);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, no);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, no);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, no);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, no);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, no);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, no);
}
impl DateInputMarkers for NeoDateComponents {
type YearInput = datetime_marker_helper!(@input/year, yes);
type MonthInput = datetime_marker_helper!(@input/month, yes);
type DayOfMonthInput = datetime_marker_helper!(@input/day_of_month, yes);
type DayOfWeekInput = datetime_marker_helper!(@input/day_of_week, yes);
type DayOfYearInput = datetime_marker_helper!(@input/day_of_year, yes);
type AnyCalendarKindInput = datetime_marker_helper!(@input/any_calendar_kind, yes);
}
impl<C: CldrCalendar> TypedDateDataMarkers<C> for NeoDateComponents {
type DateSkeletonPatternsV1Marker = datetime_marker_helper!(@dates/typed, yes);
type YearNamesV1Marker = datetime_marker_helper!(@years/typed, yes);
type MonthNamesV1Marker = datetime_marker_helper!(@months/typed, yes);
type WeekdayNamesV1Marker = datetime_marker_helper!(@weekdays, yes);
}
impl DateDataMarkers for NeoDateComponents {
type Skel = datetime_marker_helper!(@calmarkers, yes);
type Year = datetime_marker_helper!(@calmarkers, yes);
type Month = datetime_marker_helper!(@calmarkers, yes);
type WeekdayNamesV1Marker = datetime_marker_helper!(@weekdays, yes);
}
impl DateTimeMarkers for NeoDateComponents {
type D = Self;
type T = NeoNeverMarker;
type Z = NeoNeverMarker;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, yes);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, yes);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, no);
type GluePatternV1Marker = datetime_marker_helper!(@glue, no);
}
impl private::Sealed for NeoTimeComponents {}
impl IsRuntimeComponents for NeoTimeComponents {}
impl DateTimeNamesMarker for NeoTimeComponents {
type YearNames = datetime_marker_helper!(@names/year, no);
type MonthNames = datetime_marker_helper!(@names/month, no);
type WeekdayNames = datetime_marker_helper!(@names/weekday, no);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, yes);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, no);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, no);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, no);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, no);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, no);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, no);
}
impl TimeMarkers for NeoTimeComponents {
type DayPeriodNamesV1Marker = datetime_marker_helper!(@dayperiods, yes);
type TimeSkeletonPatternsV1Marker = 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 NeoTimeComponents {
type D = NeoNeverMarker;
type T = Self;
type Z = NeoNeverMarker;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, yes);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, no);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, yes);
type GluePatternV1Marker = datetime_marker_helper!(@glue, no);
}
impl private::Sealed for NeoTimeZoneSkeleton {}
impl IsRuntimeComponents for NeoTimeZoneSkeleton {}
impl DateTimeNamesMarker for NeoTimeZoneSkeleton {
type YearNames = datetime_marker_helper!(@names/year, no);
type MonthNames = datetime_marker_helper!(@names/month, no);
type WeekdayNames = datetime_marker_helper!(@names/weekday, no);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, no);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, yes);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, yes);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, yes);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, yes);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, yes);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, yes);
}
impl ZoneMarkers for NeoTimeZoneSkeleton {
type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes);
type TimeZoneIdInput = datetime_marker_helper!(@input/timezone/id, yes);
type TimeZoneMetazoneInput = datetime_marker_helper!(@input/timezone/metazone, yes);
type TimeZoneVariantInput = datetime_marker_helper!(@input/timezone/variant, yes);
type EssentialsV1Marker = datetime_marker_helper!(@data/zone/essentials, yes);
type ExemplarCitiesV1Marker = datetime_marker_helper!(@data/zone/exemplar_cities, yes);
type GenericLongV1Marker = datetime_marker_helper!(@data/zone/generic_long, yes);
type GenericShortV1Marker = datetime_marker_helper!(@data/zone/generic_short, yes);
type SpecificLongV1Marker = datetime_marker_helper!(@data/zone/specific_long, yes);
type SpecificShortV1Marker = datetime_marker_helper!(@data/zone/specific_short, yes);
}
impl DateTimeMarkers for NeoTimeZoneSkeleton {
type D = NeoNeverMarker;
type T = NeoNeverMarker;
type Z = Self;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, no);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, no);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, no);
type GluePatternV1Marker = datetime_marker_helper!(@glue, no);
}
impl private::Sealed for NeoDateTimeComponents {}
impl IsRuntimeComponents for NeoDateTimeComponents {}
impl DateTimeNamesMarker for NeoDateTimeComponents {
type YearNames = datetime_marker_helper!(@names/year, yes);
type MonthNames = datetime_marker_helper!(@names/month, yes);
type WeekdayNames = datetime_marker_helper!(@names/weekday, yes);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, yes);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, no);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, no);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, no);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, no);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, no);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, no);
}
impl DateTimeMarkers for NeoDateTimeComponents {
type D = NeoDateComponents;
type T = NeoTimeComponents;
type Z = NeoNeverMarker;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, yes);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, yes);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, yes);
type GluePatternV1Marker = datetime_marker_helper!(@glue, yes);
}
impl private::Sealed for NeoComponents {}
impl IsRuntimeComponents for NeoComponents {}
impl DateTimeNamesMarker for NeoComponents {
type YearNames = datetime_marker_helper!(@names/year, yes);
type MonthNames = datetime_marker_helper!(@names/month, yes);
type WeekdayNames = datetime_marker_helper!(@names/weekday, yes);
type DayPeriodNames = datetime_marker_helper!(@names/dayperiod, yes);
type ZoneEssentials = datetime_marker_helper!(@names/zone/essentials, yes);
type ZoneExemplarCities = datetime_marker_helper!(@names/zone/exemplar_cities, yes);
type ZoneGenericLong = datetime_marker_helper!(@names/zone/generic_long, yes);
type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, yes);
type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, yes);
type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, yes);
}
impl DateTimeMarkers for NeoComponents {
type D = NeoDateComponents;
type T = NeoTimeComponents;
type Z = NeoTimeZoneSkeleton;
type LengthOption = datetime_marker_helper!(@option/length, yes);
type AlignmentOption = datetime_marker_helper!(@option/alignment, yes);
type EraDisplayOption = datetime_marker_helper!(@option/eradisplay, yes);
type FractionalSecondDigitsOption = datetime_marker_helper!(@option/fractionalsecondigits, yes);
type GluePatternV1Marker = datetime_marker_helper!(@glue, yes);
}