summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst.js
blob: 4fb19513d4401e34b80610e52d14b189f19c7b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// 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: Sample of results for IANA time zones around DST changes
includes: [temporalHelpers.js]
features: [Temporal]
---*/

function test(epochNs, id, expected) {
  const instant = new Temporal.Instant(epochNs);
  const tz = new Temporal.TimeZone(id);
  const dt = tz.getPlainDateTimeFor(instant);
  TemporalHelpers.assertPlainDateTime(dt, ...expected, `Local time of ${instant} in ${id}`);
}

// Just before DST forward shift
test(1553993999_999_999_999n, "Europe/London", [2019, 3, "M03", 31, 0, 59, 59, 999, 999, 999]);
// Just after DST forward shift
test(1553994000_000_000_000n, "Europe/London", [2019, 3, "M03", 31, 2, 0, 0, 0, 0, 0]);
// Just before DST backward shift
test(1550368799_999_999_999n, "America/Sao_Paulo", [2019, 2, "M02", 16, 23, 59, 59, 999, 999, 999]);
// Just after DST backward shift
test(1550368800_000_000_000n, "America/Sao_Paulo", [2019, 2, "M02", 16, 23, 0, 0, 0, 0, 0]);

reportCompare(0, 0);