Skip to content

Commit

Permalink
Move datetime calendar traits to scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Oct 15, 2024
1 parent 634b563 commit 7745b80
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion components/datetime/src/format/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use super::{
GetNameForDayPeriodError, GetNameForMonthError, GetNameForWeekdayError, GetSymbolForEraError,
MonthPlaceholderValue,
};
use crate::calendar::CldrCalendar;
use crate::external_loaders::*;
use crate::fields::{self, Field, FieldLength, FieldSymbol};
use crate::helpers::size_test;
Expand All @@ -22,6 +21,7 @@ use crate::neo_skeleton::NeoDateTimeSkeleton;
use crate::pattern::PatternItem;
use crate::provider::neo::*;
use crate::provider::time_zones::tz;
use crate::scaffolding::*;
use crate::time_zone::ResolvedNeoTimeZoneSkeleton;
use crate::time_zone::TimeZoneDataPayloadsBorrowed;
use core::fmt;
Expand Down
3 changes: 0 additions & 3 deletions components/datetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@

extern crate alloc;

mod calendar;
mod error;
mod external_loaders;
pub mod fields;
Expand All @@ -116,8 +115,6 @@ pub mod skeleton;
mod time_zone;
mod tz_registry;

pub use calendar::CldrCalendar;
pub use calendar::NeverCalendar;
pub use error::MismatchedCalendarError;
pub use format::datetime::DateTimeWriteError;
pub use format::neo::{FormattedDateTimePattern, LoadError, SingleLoadError, TypedDateTimeNames};
Expand Down
8 changes: 3 additions & 5 deletions components/datetime/src/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

//! High-level entrypoints for Neo DateTime Formatter

use crate::calendar::AnyCalendarProvider;
use crate::external_loaders::*;
use crate::format::datetime::try_write_pattern_items;
use crate::format::datetime::DateTimeWriteError;
Expand All @@ -13,17 +12,16 @@ use crate::input::ExtractedInput;
use crate::neo_marker::DateInputMarkers;
use crate::neo_marker::HasConstComponents;
use crate::neo_marker::{
AllInputMarkers, CalMarkers, ConvertCalendar, DateDataMarkers, DateTimeMarkers,
IsAnyCalendarKind, IsInCalendar, IsRuntimeComponents, NeoGetField, TimeMarkers,
TypedDateDataMarkers, ZoneMarkers,
AllInputMarkers, ConvertCalendar, DateDataMarkers, DateTimeMarkers, IsAnyCalendarKind,
IsInCalendar, IsRuntimeComponents, NeoGetField, TimeMarkers, TypedDateDataMarkers, ZoneMarkers,
};
use crate::neo_pattern::DateTimePattern;
use crate::neo_skeleton::{NeoComponents, NeoSkeletonLength};
use crate::options::preferences::HourCycle;
use crate::provider::neo::*;
use crate::provider::ErasedPackedPatterns;
use crate::raw::neo::*;
use crate::CldrCalendar;
use crate::scaffolding::*;
use crate::MismatchedCalendarError;
use core::fmt;
use core::marker::PhantomData;
Expand Down
11 changes: 1 addition & 10 deletions components/datetime/src/neo_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ use crate::{
format::neo::*,
neo_skeleton::*,
provider::{neo::*, time_zones::tz, *},
scaffolding::UnstableSealed,
CldrCalendar,
scaffolding::*,
};
use icu_calendar::{
any_calendar::IntoAnyCalendar,
Expand All @@ -361,14 +360,6 @@ use icu_timezone::{
CustomTimeZone, CustomZonedDateTime, MetazoneId, TimeZoneBcp47Id, UtcOffset, ZoneVariant,
};

// TODO: Figure out where to export these traits
#[doc(inline)]
pub use crate::calendar::CalMarkers;
#[doc(inline)]
pub use crate::calendar::FullDataCalMarkers;
#[doc(inline)]
pub use crate::calendar::NoDataCalMarkers;

/// A type that can be converted into a specific calendar system.
pub trait ConvertCalendar {
/// The converted type. This can be the same as the receiver type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

//! Scaffolding traits and impls for calendars.

use icu_calendar::any_calendar::AnyCalendarKind;
use icu_calendar::chinese::Chinese;
use icu_calendar::roc::Roc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
//! Items in this module are mostly for trait bounds. Most users should not need to reference
//! these items in userland code.

mod calendar;

pub(crate) use calendar::AnyCalendarProvider;
pub use calendar::CalMarkers;
pub use calendar::CldrCalendar;
pub use calendar::FullDataCalMarkers;
pub use calendar::NeverCalendar;
pub use calendar::NoDataCalMarkers;

/// Trait marking other traits that are considered unstable and should not generally be
/// implemented outside of the datetime crate.
///
Expand Down
9 changes: 5 additions & 4 deletions components/datetime/tests/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use icu_calendar::{
AsCalendar, Calendar, DateTime, Gregorian, Iso,
};
use icu_datetime::neo_skeleton::NeoDateTimeSkeleton;
use icu_datetime::CldrCalendar;
use icu_datetime::scaffolding::CldrCalendar;
use icu_datetime::{
neo::{NeoFormatter, TypedNeoFormatter},
neo_pattern::DateTimePattern,
Expand Down Expand Up @@ -472,7 +472,8 @@ fn test_time_zone_format_configs() {
#[test]
fn test_time_zone_format_offset_seconds() {
use icu_datetime::{
neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength, NeverCalendar,
neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength,
scaffolding::NeverCalendar,
};

let time_zone = CustomTimeZone::new_with_offset(UtcOffset::try_from_seconds(12).unwrap());
Expand All @@ -487,8 +488,8 @@ fn test_time_zone_format_offset_seconds() {
#[test]
fn test_time_zone_format_offset_not_set_debug_assert_panic() {
use icu_datetime::{
neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength, DateTimeWriteError,
NeverCalendar,
neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength,
scaffolding::NeverCalendar, DateTimeWriteError,
};

let time_zone = CustomTimeZone::from_str("America/Los_Angeles");
Expand Down

0 comments on commit 7745b80

Please sign in to comment.