Rendering Duration with negative components

A rendered Duration that was constructed with negative
componented begins with a `-`, but that's the last
time a minus sign appears.
This commit is contained in:
Jesse Alama 2021-11-30 10:33:30 +01:00 committed by Rick Waldron
parent 8d025ef1d6
commit 85973b35e4
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,11 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.duration.prototype.tojson
description: Temporal.Duration.toJSON handles negative components
features: [Temporal]
---*/
const d = new Temporal.Duration(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
const expected = "-P1Y1M1W1DT1H1M1.001001001S";
assert.sameValue(d.toJSON(), expected, "toJSON with negative components");

View File

@ -0,0 +1,11 @@
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.duration.prototype.tostring
description: Temporal.Duration.toString handles negative components
features: [Temporal]
---*/
const d = new Temporal.Duration(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
const expected = "-P1Y1M1W1DT1H1M1.001001001S";
assert.sameValue(d.toString(), expected, "toString with negative components");