Source code

Revision control

Copy as Markdown

Other Tools

// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2026 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.duration.compare
description: Fractional minutes or hours in time string in relativeTo option should throw RangeError
features: [Temporal]
---*/
const instance1 = new Temporal.Duration(1, 0, 0, 0, 24)
const instance2 = new Temporal.Duration(1, 0, 0, 0, 24)
const invalidStrings = [
["2025-04-03T05:07.123", "Fractional minutes"],
["2025-04-03T12.5", "Fractional hours"],
];
for (const [arg, description] of invalidStrings) {
assert.throws(
RangeError,
() => Temporal.Duration.compare(instance1, instance2, { relativeTo: arg }),
`${description} not allowed in time string`
);
}
reportCompare(0, 0);