diff --git a/crates/provider/src/common.rs b/crates/provider/src/common.rs index dad2d4e2d..da248e1f7 100644 --- a/crates/provider/src/common.rs +++ b/crates/provider/src/common.rs @@ -250,7 +250,7 @@ impl MwdForTime { #[cfg(any(feature = "tzif", feature = "experimental_tzif"))] pub(crate) fn from_seconds(seconds: i64) -> Self { let (year, month, day_of_month) = utils::ymd_from_epoch_milliseconds(seconds * 1_000); - let week_of_month = day_of_month / 7 + 1; + let week_of_month = (day_of_month - 1) / 7 + 1; let day_of_week = utils::epoch_seconds_to_day_of_week(seconds); let mut mwd = Mwd::from_u8(month, week_of_month, day_of_week); let days_in_month = utils::iso_days_in_month(year, month); diff --git a/crates/temporal/src/builtins/compiled/plain_date_time.rs b/crates/temporal/src/builtins/compiled/plain_date_time.rs index c9d2675ef..8f745b1ae 100644 --- a/crates/temporal/src/builtins/compiled/plain_date_time.rs +++ b/crates/temporal/src/builtins/compiled/plain_date_time.rs @@ -44,4 +44,25 @@ mod tests { // Should disambiguate to 2020-03-08T01:30:00-08:00[America/Los_Angeles] assert_eq!(zdt.hour(), 3); } + + #[cfg(feature = "tzdb")] + #[test] + fn new_york_standard_time_before_dst_start() { + use crate::{options::Disambiguation, tzdb::CompiledTzdbProvider, PlainDateTime, TimeZone}; + let provider = &CompiledTzdbProvider::default(); + + // DST starts on 2026-03-08, so 2026-03-07 is still standard time. + let pdt = PlainDateTime::try_new_iso(2026, 3, 7, 12, 0, 0, 0, 0, 0).unwrap(); + let zdt = pdt + .to_zoned_date_time_with_provider( + TimeZone::try_from_identifier_str_with_provider("America/New_York", provider) + .unwrap(), + Disambiguation::Compatible, + provider, + ) + .unwrap(); + + assert_eq!(zdt.hour(), 12); + assert_eq!(zdt.offset(), "-05:00"); + } }