Skip to content

Commit

Permalink
Temporal: Add test case for rounding Duration relative to a ZonedDate…
Browse files Browse the repository at this point in the history
…Time (#4306)

This is the test for the change in tc39/proposal-temporal#3036 and is a variation of the test from tc39/proposal-temporal#2814 .
  • Loading branch information
catamorphism authored Nov 7, 2024
1 parent 26a396d commit 81df127
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.duration.prototype.round
description: Rounding mode is taken into account when largestUnit is present.
includes: [temporalHelpers.js]
features: [Temporal]
---*/

// Based on a test case by Adam Shaw

const dur = new Temporal.Duration.from(0, 0, 0, 0, /* hours = */ 13, 0, 0, 0, 0, 0);
const zdt = new Temporal.ZonedDateTime(0n, "UTC");

TemporalHelpers.assertDuration(
dur.round({
relativeTo: zdt,
largestUnit: 'hours',
smallestUnit: 'hours',
roundingIncrement: 12,
roundingMode: 'ceil'
}), 0, 0, 0, 0, 24, 0, 0, 0, 0, 0);

0 comments on commit 81df127

Please sign in to comment.