Skip to content

Commit f101cbd

Browse files
authored
Fix hoursInDay division constant (#395)
Closes #394. The constant was incorrect. This also adds a test for a basic `hour_in_day_with_provider` call.
1 parent 34522ae commit f101cbd

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/builtins/core/zoneddatetime.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ impl ZonedDateTime {
761761
// NOTE: The below should be safe as today_ns and tomorrow_ns should be at most 25 hours.
762762
// TODO: Tests for the below cast.
763763
// 10. Return 𝔽(TotalTimeDuration(diff, hour)).
764-
Ok(diff.divide(60_000_000_000) as u8)
764+
Ok(diff.divide(3_600_000_000_000) as u8)
765765
}
766766
}
767767

@@ -1643,6 +1643,21 @@ mod tests {
16431643
assert!(result.is_ok());
16441644
}
16451645

1646+
#[test]
1647+
fn zdt_hours_in_day() {
1648+
let provider = &FsTzdbProvider::default();
1649+
let zdt_str = "2025-07-04T12:00[UTC][u-ca=iso8601]";
1650+
let result = ZonedDateTime::from_str_with_provider(
1651+
zdt_str,
1652+
Disambiguation::Compatible,
1653+
OffsetDisambiguation::Reject,
1654+
provider,
1655+
)
1656+
.unwrap();
1657+
1658+
assert_eq!(result.hours_in_day_with_provider(provider).unwrap(), 24)
1659+
}
1660+
16461661
#[test]
16471662
// https://github.com/tc39/test262/blob/d9b10790bc4bb5b3e1aa895f11cbd2d31a5ec743/test/intl402/Temporal/ZonedDateTime/from/dst-skipped-cross-midnight.js
16481663
fn dst_skipped_cross_midnight() {

0 commit comments

Comments
 (0)