mirror of https://github.com/tc39/test262.git
Temporal: Add toZonedDateTime tests.
This commit is contained in:
parent
6f2e6872fb
commit
697784363f
|
@ -0,0 +1,19 @@
|
|||
// 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.plaindate.prototype.tozoneddatetime
|
||||
description: Calendar of the receiver is used
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
const timeCalendar = { toString() { return "iso8601"; } };
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
const result = plainDate.toZonedDateTime({
|
||||
timeZone: "UTC",
|
||||
plainTime: { hour: 12, minute: 30, calendar: timeCalendar },
|
||||
});
|
||||
assert.sameValue(result.epochNanoseconds, 957270600_000_000_000n);
|
||||
assert.sameValue(result.timeZone.toString(), "UTC");
|
||||
assert.sameValue(result.calendar, calendar);
|
28
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor.js
vendored
Normal file
28
test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor.js
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
// 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.plaindate.prototype.tozoneddatetime
|
||||
description: Calendar of the receiver is used
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
const calendar = new Temporal.Calendar("iso8601");
|
||||
class CustomTimeZone extends Temporal.TimeZone {
|
||||
constructor() {
|
||||
super("UTC");
|
||||
}
|
||||
getPossibleInstantsFor(plainDateTime) {
|
||||
assert.sameValue(plainDateTime.calendar, calendar);
|
||||
return [new Temporal.Instant(987654321_000_000_000n)];
|
||||
}
|
||||
}
|
||||
const timeZone = new CustomTimeZone();
|
||||
const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar);
|
||||
const result = plainDate.toZonedDateTime({
|
||||
timeZone,
|
||||
plainTime: { hour: 12, minute: 30 },
|
||||
});
|
||||
assert.sameValue(result.epochNanoseconds, 987654321_000_000_000n);
|
||||
assert.sameValue(result.timeZone, timeZone);
|
||||
assert.sameValue(result.calendar, calendar);
|
Loading…
Reference in New Issue