Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/provider/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions crates/temporal/src/builtins/compiled/plain_date_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the test_all_providers macro

If necessary, move it into a test_utils.rs file.


// 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");
}
}