Skip to content

Commit

Permalink
Make NeoComponents zone combos more consistent (#5294)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Jul 25, 2024
1 parent 334608d commit f5dc8de
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
6 changes: 2 additions & 4 deletions components/datetime/src/neo_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,10 +976,8 @@ where
T: HasConstTimeComponents,
Z: HasConstZoneComponent,
{
const COMPONENTS: NeoComponents = NeoComponents::DateTimeZone(
NeoDateTimeComponents::DateTime(D::COMPONENTS, T::COMPONENTS),
Z::COMPONENT,
);
const COMPONENTS: NeoComponents =
NeoComponents::DateTimeZone(D::COMPONENTS, T::COMPONENTS, Z::COMPONENT);
}

impl<D, T, Z> DateTimeMarkers for DateTimeCombo<D, T, Z>
Expand Down
16 changes: 10 additions & 6 deletions components/datetime/src/neo_skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,16 +709,20 @@ impl From<NeoTimeComponents> for NeoDateTimeComponents {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum NeoComponents {
/// Components for parts of a date.
/// Components for a date.
Date(NeoDateComponents),
/// Components for parts of a time.
/// Components for a time.
Time(NeoTimeComponents),
/// Components for a time zone by itself.
/// Components for a time zone.
Zone(NeoTimeZoneSkeleton),
/// Components for parts of a date and time together.
/// Components for a date and a time together.
DateTime(NeoDayComponents, NeoTimeComponents),
/// Components for a date/time with a time zone.
DateTimeZone(NeoDateTimeComponents, NeoTimeZoneSkeleton),
/// Components for a date and a time zone together.
DateZone(NeoDateComponents, NeoTimeZoneSkeleton),
/// Components for a time and a time zone together.
TimeZone(NeoTimeComponents, NeoTimeZoneSkeleton),
/// Components for a date, a time, and a time zone together.
DateTimeZone(NeoDayComponents, NeoTimeComponents, NeoTimeZoneSkeleton),
}

impl From<NeoDateComponents> for NeoComponents {
Expand Down
19 changes: 5 additions & 14 deletions components/datetime/src/raw/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::format::neo::FieldForDataLoading;
use crate::input::ExtractedDateTimeInput;
use crate::neo_pattern::DateTimePattern;
use crate::neo_skeleton::{
NeoComponents, NeoDateComponents, NeoDateSkeleton, NeoDateTimeComponents, NeoSkeletonLength,
NeoTimeComponents, NeoTimeSkeleton, NeoTimeZoneSkeleton,
NeoComponents, NeoDateComponents, NeoDateSkeleton, NeoSkeletonLength, NeoTimeComponents,
NeoTimeSkeleton, NeoTimeZoneSkeleton,
};
use crate::pattern::runtime::PatternMetadata;
use crate::pattern::{runtime, GenericPatternItem, PatternItem};
Expand Down Expand Up @@ -306,10 +306,7 @@ impl DateTimeZonePatternSelectionData {
let glue = Self::load_glue(glue_provider, locale, length, GlueType::DateTime)?;
Ok(Self::DateTimeGlue { date, time, glue })
}
NeoComponents::DateTimeZone(
NeoDateTimeComponents::Date(date_components),
zone_components,
) => {
NeoComponents::DateZone(date_components, zone_components) => {
let date = DatePatternSelectionData::try_new_with_skeleton(
date_provider,
locale,
Expand All @@ -320,10 +317,7 @@ impl DateTimeZonePatternSelectionData {
let glue = Self::load_glue(glue_provider, locale, length, GlueType::DateZone)?;
Ok(Self::DateZoneGlue { date, zone, glue })
}
NeoComponents::DateTimeZone(
NeoDateTimeComponents::Time(time_components),
zone_components,
) => {
NeoComponents::TimeZone(time_components, zone_components) => {
let time = TimePatternSelectionData::try_new_with_skeleton(
time_provider,
locale,
Expand All @@ -334,10 +328,7 @@ impl DateTimeZonePatternSelectionData {
let glue = Self::load_glue(glue_provider, locale, length, GlueType::TimeZone)?;
Ok(Self::TimeZoneGlue { time, zone, glue })
}
NeoComponents::DateTimeZone(
NeoDateTimeComponents::DateTime(day_components, time_components),
zone_components,
) => {
NeoComponents::DateTimeZone(day_components, time_components, zone_components) => {
let date = DatePatternSelectionData::try_new_with_skeleton(
date_provider,
locale,
Expand Down

0 comments on commit f5dc8de

Please sign in to comment.