@@ -50,7 +50,7 @@ let icu_zdt = ZonedDateTime::<Iso, _>::convert_from(&zdt);
50
50
// Format for the en-GB locale:
51
51
let formatter = DateTimeFormatter::try_new(
52
52
locale!("en-GB").into(),
53
- fieldsets::YMDET::medium().zone (fieldsets::zone::SpecificLong),
53
+ fieldsets::YMDET::medium().with_zone (fieldsets::zone::SpecificLong),
54
54
)?;
55
55
assert_eq!(
56
56
formatter.format(&icu_zdt).to_string(),
@@ -60,17 +60,17 @@ assert_eq!(
60
60
// Or in the en-US locale:
61
61
let formatter = DateTimeFormatter::try_new(
62
62
locale!("en-US").into(),
63
- fieldsets::YMDET::medium().zone (fieldsets::zone::SpecificShort),
63
+ fieldsets::YMDET::medium().with_zone (fieldsets::zone::SpecificShort),
64
64
)?;
65
65
assert_eq!(
66
66
formatter.format(&icu_zdt).to_string(),
67
67
"Tue, Sep 10, 2024, 11:37:20 PM EDT",
68
68
);
69
69
70
- // Or in the default or "unknown" locale:
70
+ // Or in the "unknown" locale:
71
71
let formatter = DateTimeFormatter::try_new(
72
- icu::locale::Locale::default() .into(),
73
- fieldsets::YMDET::medium().zone (fieldsets::zone::SpecificShort),
72
+ icu::locale::Locale::UNKNOWN .into(),
73
+ fieldsets::YMDET::medium().with_zone (fieldsets::zone::SpecificShort),
74
74
)?;
75
75
assert_eq!(
76
76
formatter.format(&icu_zdt).to_string(),
@@ -163,15 +163,16 @@ use icu_calendar::{
163
163
types:: Weekday as IcuWeekday , AsCalendar as IcuAsCalendar ,
164
164
Date as IcuDate , Iso ,
165
165
} ;
166
- #[ cfg( feature = "zoned" ) ]
167
- use icu_time:: {
168
- provider:: TimeZoneVariant , zone:: models:: Full , TimeZone as IcuTimeZone ,
169
- TimeZoneInfo as IcuTimeZoneInfo , ZonedDateTime as IcuZonedDateTime ,
170
- } ;
171
166
#[ cfg( feature = "time" ) ]
172
167
use icu_time:: {
173
168
zone:: UtcOffset as IcuUtcOffset , DateTime as IcuDateTime , Time as IcuTime ,
174
169
} ;
170
+ #[ cfg( feature = "zoned" ) ]
171
+ use icu_time:: {
172
+ zone:: { models:: Full , TimeZoneVariant } ,
173
+ TimeZone as IcuTimeZone , TimeZoneInfo as IcuTimeZoneInfo ,
174
+ ZonedDateTime as IcuZonedDateTime ,
175
+ } ;
175
176
176
177
use jiff:: civil:: { Date as JiffDate , Weekday as JiffWeekday } ;
177
178
#[ cfg( feature = "time" ) ]
@@ -354,7 +355,7 @@ impl<C: IcuAsCalendar> ConvertTryFrom<IcuDate<C>> for JiffDate {
354
355
355
356
fn convert_try_from ( v : IcuDate < C > ) -> Result < JiffDate , Error > {
356
357
let v = v. to_iso ( ) ;
357
- let year = v. year ( ) . extended_year ;
358
+ let year = v. extended_year ( ) ;
358
359
let year = i16:: try_from ( year) . map_err ( |_| {
359
360
err ! ( "failed to convert `icu` year of {year} to `i16`" )
360
361
} ) ?;
@@ -420,7 +421,7 @@ impl<C: IcuAsCalendar> ConvertTryFrom<IcuDate<C>> for JiffDate {
420
421
/// let icu_hebrew_date = icu_iso_date.to_calendar(icu_calendar::cal::Hebrew);
421
422
/// assert_eq!(
422
423
/// format!("{icu_hebrew_date:?}"),
423
- /// "Date(5785-5-4, hebrew era, for calendar Hebrew)",
424
+ /// "Date(5785-5-4, am era, for calendar Hebrew)",
424
425
/// );
425
426
/// ```
426
427
impl ConvertFrom < JiffDate > for IcuDate < Iso > {
@@ -611,14 +612,14 @@ impl ConvertTryFrom<JiffOffset> for IcuUtcOffset {
611
612
/// let icu_tz = icu_time::TimeZone::convert_from(jiff_tz);
612
613
/// assert_eq!(
613
614
/// format!("{icu_tz:?}"),
614
- /// "TimeZone(\"usnyc\")",
615
+ /// "TimeZone(Subtag( \"usnyc\") )",
615
616
/// );
616
617
///
617
618
/// let jiff_tz = jiff::tz::TimeZone::get("us/eastern")?;
618
619
/// let icu_tz = icu_time::TimeZone::convert_from(jiff_tz);
619
620
/// assert_eq!(
620
621
/// format!("{icu_tz:?}"),
621
- /// "TimeZone(\"usnyc\")",
622
+ /// "TimeZone(Subtag( \"usnyc\") )",
622
623
/// );
623
624
///
624
625
/// // If there's no IANA identifier for the Jiff time zone, then
@@ -627,7 +628,7 @@ impl ConvertTryFrom<JiffOffset> for IcuUtcOffset {
627
628
/// let icu_tz = icu_time::TimeZone::convert_from(jiff_tz);
628
629
/// assert_eq!(
629
630
/// format!("{icu_tz:?}"),
630
- /// "TimeZone(\"unk\")",
631
+ /// "TimeZone(Subtag( \"unk\") )",
631
632
/// );
632
633
///
633
634
/// // An explicitly unknown Jiff time zone is equivalent to an
@@ -636,7 +637,7 @@ impl ConvertTryFrom<JiffOffset> for IcuUtcOffset {
636
637
/// let icu_tz = icu_time::TimeZone::convert_from(jiff_tz);
637
638
/// assert_eq!(
638
639
/// format!("{icu_tz:?}"),
639
- /// "TimeZone(\"unk\")",
640
+ /// "TimeZone(Subtag( \"unk\") )",
640
641
/// );
641
642
///
642
643
/// # Ok::<(), Box<dyn std::error::Error>>(())
@@ -654,7 +655,7 @@ impl ConvertFrom<JiffTimeZone> for IcuTimeZone {
654
655
impl < ' a > ConvertFrom < & ' a JiffTimeZone > for IcuTimeZone {
655
656
fn convert_from ( v : & ' a JiffTimeZone ) -> IcuTimeZone {
656
657
let Some ( iana_name) = v. iana_name ( ) else {
657
- return IcuTimeZone :: unknown ( ) ;
658
+ return IcuTimeZone :: UNKNOWN ;
658
659
} ;
659
660
icu_time:: zone:: iana:: IanaParser :: new ( ) . parse ( iana_name)
660
661
}
@@ -681,8 +682,8 @@ impl<'a> ConvertFrom<&'a JiffTimeZone> for IcuTimeZone {
681
682
/// "Time { hour: Hour(17), minute: Minute(58), second: Second(30), subsecond: Nanosecond(0) }",
682
683
/// );
683
684
/// assert_eq!(
684
- /// format!("{:?}", (icu_zdt.zone.time_zone_id (), icu_zdt.zone.offset())),
685
- /// "(TimeZone(\"usnyc\"), Some(UtcOffset(-18000)))",
685
+ /// format!("{:?}", (icu_zdt.zone.id (), icu_zdt.zone.offset())),
686
+ /// "(TimeZone(Subtag( \"usnyc\") ), Some(UtcOffset(-18000)))",
686
687
/// );
687
688
///
688
689
/// # Ok::<(), Box<dyn std::error::Error>>(())
@@ -696,13 +697,14 @@ impl<'a> ConvertFrom<&'a JiffZoned>
696
697
) -> IcuZonedDateTime < Iso , IcuTimeZoneInfo < Full > > {
697
698
let date = IcuDate :: convert_from ( v. date ( ) ) ;
698
699
let time = IcuTime :: convert_from ( v. time ( ) ) ;
700
+ let datetime = IcuDateTime { date, time } ;
699
701
700
702
let tz = IcuTimeZone :: convert_from ( v. time_zone ( ) ) ;
701
703
let offset = IcuUtcOffset :: convert_try_from ( v. offset ( ) ) . ok ( ) ;
702
704
let dst = v. time_zone ( ) . to_offset_info ( v. timestamp ( ) ) . dst ( ) . is_dst ( ) ;
703
705
let tz_info_base = tz. with_offset ( offset) ;
704
- let tz_info_at = tz_info_base. at_time ( ( date , time ) ) ;
705
- let zone = tz_info_at. with_zone_variant ( if dst {
706
+ let tz_info_at = tz_info_base. at_date_time_iso ( datetime ) ;
707
+ let zone = tz_info_at. with_variant ( if dst {
706
708
TimeZoneVariant :: Daylight
707
709
} else {
708
710
TimeZoneVariant :: Standard
0 commit comments