relativeto-hour.js (1048B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2022 Igalia, S.L. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-temporal.duration.compare 7 description: relativeTo with hours. 8 features: [Temporal] 9 ---*/ 10 11 const oneDay = new Temporal.Duration(0, 0, 0, 1); 12 const hours24 = new Temporal.Duration(0, 0, 0, 0, 24); 13 assert.sameValue(Temporal.Duration.compare(oneDay, hours24), 14 0, 15 "relativeTo not required for days"); 16 assert.sameValue( 17 Temporal.Duration.compare(oneDay, hours24, { relativeTo: Temporal.PlainDate.from("2017-01-01") }), 18 0, 19 "relativeTo does not affect days if PlainDate"); 20 assert.sameValue(Temporal.Duration.compare(oneDay, hours24, { relativeTo: "2019-11-03" }), 21 0, 22 "casts relativeTo to PlainDate from string"); 23 assert.sameValue(Temporal.Duration.compare(oneDay, hours24, { relativeTo: { year: 2019, month: 11, day: 3 } }), 24 0, 25 "casts relativeTo to PlainDate from object"); 26 27 reportCompare(0, 0);