Test conversion of Temporal.Instant strings with sub-minute UTC offsets

This commit is contained in:
Philip Chimento 2022-04-14 17:39:34 -07:00 committed by Philip Chimento
parent 9cd27beb12
commit d28ca991cb
6 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.compare
description: Temporal.Instant string with sub-minute offset
features: [Temporal]
---*/
const epoch = new Temporal.Instant(0n);
const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result1 = Temporal.Instant.compare(str, epoch);
assert.sameValue(result1, 0, "if present, sub-minute offset is accepted exactly (first argument)");
const result2 = Temporal.Instant.compare(epoch, str);
assert.sameValue(result2, 0, "if present, sub-minute offset is accepted exactly (second argument)");

View File

@ -0,0 +1,12 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.from
description: Temporal.Instant string with sub-minute offset
features: [Temporal]
---*/
const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result = Temporal.Instant.from(str);
assert.sameValue(result.epochNanoseconds, 0n, "if present, sub-minute offset is accepted exactly");

View File

@ -0,0 +1,14 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.prototype.equals
description: Temporal.Instant string with sub-minute offset
features: [Temporal]
---*/
const instance = new Temporal.Instant(0n);
const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result = instance.equals(str);
assert.sameValue(result, true, "if present, sub-minute offset is accepted exactly");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.prototype.since
description: Temporal.Instant string with sub-minute offset
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Instant(0n);
const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result = instance.since(str);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.instant.prototype.until
description: Temporal.Instant string with sub-minute offset
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.Instant(0n);
const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result = instance.until(str);
TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.timezone.prototype.getplaindatetimefor
description: Temporal.Instant string with sub-minute offset
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const instance = new Temporal.TimeZone("UTC");
const str = "1970-01-01T00:19:32.37+00:19:32.37";
const result = instance.getPlainDateTimeFor(str);
TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly");