LibJS: Use correct epoch offset in InterpretISODateTimeOffset

This commit is contained in:
Timothy Flynn 2024-11-26 12:36:32 -05:00 committed by Tim Flynn
commit 7aee254708
Notes: github-actions[bot] 2024-11-26 20:15:20 +00:00
2 changed files with 11 additions and 1 deletions

View file

@ -114,7 +114,7 @@ ThrowCompletionOr<Crypto::SignedBigInteger> interpret_iso_date_time_offset(VM& v
auto rounded_candidate_nanoseconds = round_number_to_increment(candidate_offset, NANOSECONDS_PER_MINUTE, RoundingMode::HalfExpand); auto rounded_candidate_nanoseconds = round_number_to_increment(candidate_offset, NANOSECONDS_PER_MINUTE, RoundingMode::HalfExpand);
// ii. If roundedCandidateNanoseconds = offsetNanoseconds, then // ii. If roundedCandidateNanoseconds = offsetNanoseconds, then
if (candidate_offset.compare_to_double(offset_nanoseconds) == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt) { if (rounded_candidate_nanoseconds.compare_to_double(offset_nanoseconds) == Crypto::UnsignedBigInteger::CompareResult::DoubleEqualsBigInt) {
// 1. Return candidate. // 1. Return candidate.
return move(candidate); return move(candidate);
} }

View file

@ -39,6 +39,16 @@ describe("correct behavior", () => {
expect(result).toBe(1); expect(result).toBe(1);
}); });
}); });
test("match minutes", () => {
const duration = new Temporal.Duration(1, 0, 0, 0, 24);
const result = duration.total({
unit: "days",
relativeTo: "1970-01-01T00:00:00-00:45[Africa/Monrovia]",
});
expect(result).toBe(366);
});
}); });
describe("errors", () => { describe("errors", () => {