summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-ambiguous-wall-clock-time.js
blob: 87d3c908acb16e817513bee0b33ad9001960fd46 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2023 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.zoneddatetime.from
description: >
  Correct time zone calls are made when converting a ZonedDateTime-like property
  bag denoting an ambiguous wall-clock time
includes: [temporalHelpers.js, compareArray.js]
features: [Temporal]
---*/

const actual = [];

const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone();
const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
  getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone),
  getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone),
});
const calendar = TemporalHelpers.calendarObserver(actual, "calendar");

const expected = [
  // GetTemporalCalendarSlotValueWithISODefault
  "has calendar.dateAdd",
  "has calendar.dateFromFields",
  "has calendar.dateUntil",
  "has calendar.day",
  "has calendar.dayOfWeek",
  "has calendar.dayOfYear",
  "has calendar.daysInMonth",
  "has calendar.daysInWeek",
  "has calendar.daysInYear",
  "has calendar.fields",
  "has calendar.id",
  "has calendar.inLeapYear",
  "has calendar.mergeFields",
  "has calendar.month",
  "has calendar.monthCode",
  "has calendar.monthDayFromFields",
  "has calendar.monthsInYear",
  "has calendar.weekOfYear",
  "has calendar.year",
  "has calendar.yearMonthFromFields",
  "has calendar.yearOfWeek",
  // lookup in ToTemporalZonedDateTime
  "get calendar.dateFromFields",
  "get calendar.fields",
  // CalendarFields
  "call calendar.fields",
  // ToTemporalTimeZoneSlotValue
  "has timeZone.getOffsetNanosecondsFor",
  "has timeZone.getPossibleInstantsFor",
  "has timeZone.id",
  // InterpretTemporalDateTimeFields
  "call calendar.dateFromFields",
  // lookup in ToTemporalZonedDateTime
  "get timeZone.getOffsetNanosecondsFor",
  "get timeZone.getPossibleInstantsFor",
];

Temporal.ZonedDateTime.from(
  { year: 2000, month: 4, day: 2, hour: 2, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "use" }
);
assert.compareArray(actual, expected, "order of operations converting property bag at skipped wall-clock time with offset: use");
actual.splice(0); // clear

Temporal.ZonedDateTime.from(
  { year: 2000, month: 4, day: 2, hour: 2, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "ignore" }
);
assert.compareArray(actual, expected.concat([
  // InterpretISODateTimeOffset
  "call timeZone.getPossibleInstantsFor",
  // DisambiguatePossibleInstants
  "call timeZone.getOffsetNanosecondsFor",
  "call timeZone.getOffsetNanosecondsFor",
  "call timeZone.getPossibleInstantsFor",
]), "order of operations converting property bag at skipped wall-clock time with offset: ignore");
actual.splice(0); // clear

Temporal.ZonedDateTime.from(
  { year: 2000, month: 4, day: 2, hour: 2, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "prefer" }
);
assert.compareArray(actual, expected.concat([
  // InterpretISODateTimeOffset
  "call timeZone.getPossibleInstantsFor",
  // DisambiguatePossibleInstants
  "call timeZone.getOffsetNanosecondsFor",
  "call timeZone.getOffsetNanosecondsFor",
  "call timeZone.getPossibleInstantsFor",
]), "order of operations converting property bag at skipped wall-clock time with offset: prefer");
actual.splice(0); // clear

Temporal.ZonedDateTime.from(
  { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "use" }
);
assert.compareArray(actual, expected, "order of operations converting property bag at repeated wall-clock time with offset: use");
actual.splice(0); // clear

Temporal.ZonedDateTime.from(
  { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "ignore" }
);
assert.compareArray(actual, expected.concat([
  // InterpretISODateTimeOffset
  "call timeZone.getPossibleInstantsFor",
]), "order of operations converting property bag at repeated wall-clock time with offset: ignore");
actual.splice(0); // clear

Temporal.ZonedDateTime.from(
  { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "prefer" }
);
assert.compareArray(actual, expected.concat([
  // InterpretISODateTimeOffset
  "call timeZone.getPossibleInstantsFor",
  "call timeZone.getOffsetNanosecondsFor",
  "call timeZone.getOffsetNanosecondsFor",
]), "order of operations converting property bag at repeated wall-clock time with offset: prefer");
actual.splice(0); // clear

Temporal.ZonedDateTime.from(
  { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar },
  { offset: "reject" }
);
assert.compareArray(actual, expected.concat([
  // InterpretISODateTimeOffset
  "call timeZone.getPossibleInstantsFor",
  "call timeZone.getOffsetNanosecondsFor",
  "call timeZone.getOffsetNanosecondsFor",
]), "order of operations converting property bag at repeated wall-clock time with offset: reject");
actual.splice(0); // clear

reportCompare(0, 0);