mirror of
https://github.com/tc39/test262.git
synced 2025-09-25 11:08:49 +02:00
Checking whether an object implements the TimeZone protocol is now done by means of HasProperty operations for each of the required methods unless the object already has the TimeZone brand. Discussion: https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753 Corresponding normative PR: https://github.com/tc39/proposal-temporal/pull/2485
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
esid: sec-temporal.now.plaindatetimeiso
|
|
description: Observable interactions with the provided timezone-like object
|
|
includes: [compareArray.js, temporalHelpers.js]
|
|
features: [BigInt, Proxy, Temporal]
|
|
---*/
|
|
const actual = [];
|
|
|
|
const expected = [
|
|
'has timeZone.getOffsetNanosecondsFor',
|
|
'has timeZone.getPossibleInstantsFor',
|
|
'has timeZone.id',
|
|
'get timeZone.getOffsetNanosecondsFor',
|
|
'call timeZone.getOffsetNanosecondsFor'
|
|
];
|
|
|
|
const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
|
|
getOffsetNanosecondsFor(instant) {
|
|
assert.sameValue(
|
|
instant instanceof Temporal.Instant,
|
|
true,
|
|
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
|
);
|
|
|
|
return -Number(instant.epochNanoseconds % 86400000000000n);
|
|
}
|
|
});
|
|
|
|
Object.defineProperty(Temporal.TimeZone, 'from', {
|
|
get() {
|
|
actual.push('get Temporal.TimeZone.from');
|
|
return undefined;
|
|
}
|
|
});
|
|
|
|
Temporal.Now.plainDateTimeISO(timeZone);
|
|
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|