Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Dec 20, 2024
1 parent e169ee4 commit b447e63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 6 additions & 3 deletions components/datetime/src/scaffold/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,16 @@ impl<O: TimeZoneModel> InSameCalendar for TimeZoneInfo<O> {
/// An input associated with a fixed, static calendar.
pub trait InFixedCalendar<C> {}

impl<C: Calendar, A: AsCalendar<Calendar = C>> InFixedCalendar<C> for Date<A> {}
impl<C: CldrCalendar, A: AsCalendar<Calendar = C>> InFixedCalendar<C> for Date<A> {}

impl<C> InFixedCalendar<C> for Time {}

impl<C: Calendar, A: AsCalendar<Calendar = C>> InFixedCalendar<C> for DateTime<A> {}
impl<C: CldrCalendar, A: AsCalendar<Calendar = C>> InFixedCalendar<C> for DateTime<A> {}

impl<C: Calendar, A: AsCalendar<Calendar = C>, Z> InFixedCalendar<C> for CustomZonedDateTime<A, Z> {}
impl<C: CldrCalendar, A: AsCalendar<Calendar = C>, Z> InFixedCalendar<C>
for CustomZonedDateTime<A, Z>
{
}

impl<C> InFixedCalendar<C> for UtcOffset {}

Expand Down
14 changes: 7 additions & 7 deletions ffi/capi/src/zoned_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#[diplomat::attr(auto, namespace = "icu4x")]
pub mod ffi {
use alloc::boxed::Box;
use icu_datetime::fieldsets::YMDTV;
use icu_datetime::fieldsets::{Combo, Vs, YMDT};
#[cfg(any(feature = "compiled_data", feature = "buffer_provider"))]
use icu_datetime::options::Length;
use icu_timezone::ZoneVariant;
Expand All @@ -32,7 +32,7 @@ pub mod ffi {
/// An object capable of formatting a date time with time zone to a string.
#[diplomat::rust_link(icu::datetime, Mod)]
pub struct GregorianZonedDateTimeFormatter(
pub icu_datetime::FixedCalendarDateTimeFormatter<icu_calendar::Gregorian, YMDTV>,
pub icu_datetime::FixedCalendarDateTimeFormatter<icu_calendar::Gregorian, Combo<YMDT, Vs>>,
);

impl GregorianZonedDateTimeFormatter {
Expand All @@ -48,7 +48,7 @@ pub mod ffi {
length: DateTimeLength,
) -> Result<Box<GregorianZonedDateTimeFormatter>, DateTimeFormatterLoadError> {
let prefs = (&locale.0).into();
let options = YMDTV::with_length(Length::from(length));
let options = YMDT::with_length(Length::from(length)).with_zone_generic();

Ok(Box::new(GregorianZonedDateTimeFormatter(
icu_datetime::FixedCalendarDateTimeFormatter::try_new(prefs, options)?,
Expand All @@ -66,7 +66,7 @@ pub mod ffi {
length: DateTimeLength,
) -> Result<Box<GregorianZonedDateTimeFormatter>, DateTimeFormatterLoadError> {
let prefs = (&locale.0).into();
let options = YMDTV::with_length(Length::from(length));
let options = YMDT::with_length(Length::from(length)).with_zone_generic();

Ok(Box::new(GregorianZonedDateTimeFormatter(
provider.call_constructor_custom_err(move |provider| {
Expand Down Expand Up @@ -101,7 +101,7 @@ pub mod ffi {
#[diplomat::opaque]
/// An object capable of formatting a date time with time zone to a string.
#[diplomat::rust_link(icu::datetime, Mod)]
pub struct ZonedDateTimeFormatter(pub icu_datetime::DateTimeFormatter<YMDTV>);
pub struct ZonedDateTimeFormatter(pub icu_datetime::DateTimeFormatter<Combo<YMDT, Vs>>);

impl ZonedDateTimeFormatter {
/// Creates a new [`ZonedDateTimeFormatter`] from locale data using compiled data.
Expand All @@ -116,7 +116,7 @@ pub mod ffi {
length: DateTimeLength,
) -> Result<Box<ZonedDateTimeFormatter>, DateTimeFormatterLoadError> {
let prefs = (&locale.0).into();
let options = YMDTV::with_length(Length::from(length));
let options = YMDT::with_length(Length::from(length)).with_zone_generic();

Ok(Box::new(ZonedDateTimeFormatter(
icu_datetime::DateTimeFormatter::try_new(prefs, options)?,
Expand All @@ -134,7 +134,7 @@ pub mod ffi {
length: DateTimeLength,
) -> Result<Box<ZonedDateTimeFormatter>, DateTimeFormatterLoadError> {
let prefs = (&locale.0).into();
let options = YMDTV::with_length(Length::from(length));
let options = YMDT::with_length(Length::from(length)).with_zone_generic();

Ok(Box::new(ZonedDateTimeFormatter(
provider.call_constructor_custom_err(move |provider| {
Expand Down

0 comments on commit b447e63

Please sign in to comment.