string-with-skipped-units.js (1229B)
1 // |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally 2 // Copyright (C) 2021 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.from 7 description: | 8 Creating a Duration from an ISO 8601 string with an absent designator between 9 two other designators 10 includes: [temporalHelpers.js] 11 features: [Temporal] 12 ---*/ 13 14 // Date designators: years-weeks (months missing) 15 16 const d1 = Temporal.Duration.from("P3Y4W"); 17 TemporalHelpers.assertDuration(d1, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, "years-weeks string"); 18 19 // Date designators: years-days (months and weeks missing) 20 21 const d2 = Temporal.Duration.from("P3Y4D"); 22 TemporalHelpers.assertDuration(d2, 3, 0, 0, 4, 0, 0, 0, 0, 0, 0, "years-days string"); 23 24 // Date designators: months-days (weeks missing) 25 26 const d3 = Temporal.Duration.from("P3M4D"); 27 TemporalHelpers.assertDuration(d3, 0, 3, 0, 4, 0, 0, 0, 0, 0, 0, "months-days string"); 28 29 // Time designators: hours-seconds (minutes missing) 30 31 const d4 = Temporal.Duration.from("PT3H4.123456789S"); 32 TemporalHelpers.assertDuration(d4, 0, 0, 0, 0, 3, 0, 4, 123, 456, 789, "hours-seconds string"); 33 34 reportCompare(0, 0);