1 // Copyright 2021 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/builtins/builtins-utils-inl.h"
6 #include "src/builtins/builtins.h"
7 #include "src/objects/bigint.h"
8 #include "src/objects/js-temporal-objects-inl.h"
9
10 namespace v8 {
11 namespace internal {
12
13 #define TO_BE_IMPLEMENTED(id) \
14 BUILTIN_NO_RCS(id) { \
15 HandleScope scope(isolate); \
16 UNIMPLEMENTED(); \
17 }
18
19 #define TEMPORAL_NOW0(T) \
20 BUILTIN(TemporalNow##T) { \
21 HandleScope scope(isolate); \
22 RETURN_RESULT_OR_FAILURE(isolate, JSTemporal##T::Now(isolate)); \
23 }
24
25 #define TEMPORAL_NOW2(T) \
26 BUILTIN(TemporalNow##T) { \
27 HandleScope scope(isolate); \
28 RETURN_RESULT_OR_FAILURE( \
29 isolate, JSTemporal##T::Now(isolate, args.atOrUndefined(isolate, 1), \
30 args.atOrUndefined(isolate, 2))); \
31 }
32
33 #define TEMPORAL_NOW_ISO1(T) \
34 BUILTIN(TemporalNow##T##ISO) { \
35 HandleScope scope(isolate); \
36 RETURN_RESULT_OR_FAILURE( \
37 isolate, \
38 JSTemporal##T::NowISO(isolate, args.atOrUndefined(isolate, 1))); \
39 }
40
41 /* Temporal #sec-temporal.plaindate.compare */
42 TO_BE_IMPLEMENTED(TemporalPlainDateCompare)
43 /* Temporal #sec-temporal.plaindate.prototype.toplainyearmonth */
TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainYearMonth)44 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainYearMonth)
45 /* Temporal #sec-temporal.plaindate.prototype.toplainmonthday */
46 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainMonthDay)
47 /* Temporal #sec-temporal.plaindate.prototype.add */
48 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeAdd)
49 /* Temporal #sec-temporal.plaindate.prototype.substract */
50 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSubtract)
51 /* Temporal #sec-temporal.plaindate.prototype.with */
52 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeWith)
53 /* Temporal #sec-temporal.plaindate.prototype.until */
54 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeUntil)
55 /* Temporal #sec-temporal.plaindate.prototype.since */
56 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSince)
57 /* Temporal #sec-temporal.plaindate.prototype.equals */
58 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeEquals)
59 /* Temporal #sec-temporal.plaindate.prototype.toplaindatetime */
60 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainDateTime)
61 /* Temporal #sec-temporal.plaindate.prototype.tozoneddatetime */
62 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToZonedDateTime)
63 /* Temporal #sec-temporal.plaindate.prototype.tostring */
64 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToString)
65 /* Temporal #sec-temporal.plaindate.prototype.tojson */
66 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToJSON)
67
68 /* Temporal.PlaneTime */
69 /* Temporal #sec-temporal.plaintime.compare */
70 TO_BE_IMPLEMENTED(TemporalPlainTimeCompare)
71 /* Temporal #sec-temporal.plaintime.prototype.add */
72 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeAdd)
73 /* Temporal #sec-temporal.plaintime.prototype.subtract */
74 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeSubtract)
75 /* Temporal #sec-temporal.plaintime.prototype.with */
76 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeWith)
77 /* Temporal #sec-temporal.plaintime.prototype.until */
78 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeUntil)
79 /* Temporal #sec-temporal.plaintime.prototype.since */
80 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeSince)
81 /* Temporal #sec-temporal.plaintime.prototype.round */
82 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeRound)
83 /* Temporal #sec-temporal.plaintime.prototype.equals */
84 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeEquals)
85 /* Temporal #sec-temporal.plaintime.prototype.toplaindatetime */
86 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToPlainDateTime)
87 /* Temporal #sec-temporal.plaintime.prototype.tozoneddatetime */
88 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToZonedDateTime)
89 /* Temporal #sec-temporal.plaintime.prototype.tostring */
90 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToString)
91 /* Temporal #sec-temporal.plaindtimeprototype.tojson */
92 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToJSON)
93
94 /* Temporal.PlaneDateTime */
95 /* Temporal #sec-temporal.plaindatetime.from */
96 TO_BE_IMPLEMENTED(TemporalPlainDateTimeFrom)
97 /* Temporal #sec-temporal.plaindatetime.compare */
98 TO_BE_IMPLEMENTED(TemporalPlainDateTimeCompare)
99 /* Temporal #sec-temporal.plaindatetime.prototype.with */
100 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWith)
101 /* Temporal #sec-temporal.plaindatetime.prototype.withplainTime */
102 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithPlainTime)
103 /* Temporal #sec-temporal.plaindatetime.prototype.withplainDate */
104 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithPlainDate)
105 /* Temporal #sec-temporal.plaindatetime.prototype.add */
106 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeAdd)
107 /* Temporal #sec-temporal.plaindatetime.prototype.subtract */
108 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeSubtract)
109 /* Temporal #sec-temporal.plaindatetime.prototype.until */
110 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeUntil)
111 /* Temporal #sec-temporal.plaindatetime.prototype.since */
112 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeSince)
113 /* Temporal #sec-temporal.plaindatetime.prototype.round */
114 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeRound)
115 /* Temporal #sec-temporal.plaindatetime.prototype.equals */
116 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeEquals)
117 /* Temporal #sec-temporal.plaindatetime.prototype.tostring */
118 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToString)
119 /* Temporal #sec-temporal.plainddatetimeprototype.tojson */
120 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToJSON)
121 /* Temporal #sec-temporal.plaindatetime.prototype.tozoneddatetime */
122 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToZonedDateTime)
123 /* Temporal #sec-temporal.plaindatetime.prototype.toplaindate */
124 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainDate)
125 /* Temporal #sec-temporal.plaindatetime.prototype.toplainyearmonth */
126 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainYearMonth)
127 /* Temporal #sec-temporal.plaindatetime.prototype.toplainmonthday */
128 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainMonthDay)
129 /* Temporal #sec-temporal.plaindatetime.prototype.toplaintime */
130 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainTime)
131
132 /* Temporal.ZonedDateTime */
133 /* Temporal #sec-temporal.zoneddatetime.from */
134 TO_BE_IMPLEMENTED(TemporalZonedDateTimeFrom)
135 /* Temporal #sec-temporal.zoneddatetime.compare */
136 TO_BE_IMPLEMENTED(TemporalZonedDateTimeCompare)
137 /* Temporal #sec-get-temporal.zoneddatetime.prototype.year */
138 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeYear)
139 /* Temporal #sec-get-temporal.zoneddatetime.prototype.month */
140 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeMonth)
141 /* Temporal #sec-get-temporal.zoneddatetime.prototype.monthcode */
142 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeMonthCode)
143 /* Temporal #sec-get-temporal.zoneddatetime.prototype.day */
144 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDay)
145 /* Temporal #sec-get-temporal.zoneddatetime.prototype.dayofweek */
146 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDayOfWeek)
147 /* Temporal #sec-get-temporal.zoneddatetime.prototype.dayofyear */
148 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDayOfYear)
149 /* Temporal #sec-get-temporal.zoneddatetime.prototype.weekofyear */
150 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWeekOfYear)
151 /* Temporal #sec-get-temporal.zoneddatetime.prototype.hoursinday */
152 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeHoursInDay)
153 /* Temporal #sec-get-temporal.zoneddatetime.prototype.daysinweek */
154 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDaysInWeek)
155 /* Temporal #sec-get-temporal.zoneddatetime.prototype.daysinmonth */
156 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDaysInMonth)
157 /* Temporal #sec-get-temporal.zoneddatetime.prototype.daysinyear */
158 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDaysInYear)
159 /* Temporal #sec-get-temporal.zoneddatetime.prototype.monthsinyear */
160 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeMonthsInYear)
161 /* Temporal #sec-get-temporal.zoneddatetime.prototype.inleapyear */
162 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeInLeapYear)
163 /* Temporal #sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds */
164 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeOffsetNanoseconds)
165 /* Temporal #sec-get-temporal.zoneddatetime.prototype.offset */
166 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeOffset)
167 /* Temporal #sec-temporal.zoneddatetime.prototype.with */
168 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWith)
169 /* Temporal #sec-temporal.zoneddatetime.prototype.withplaintime */
170 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainTime)
171 /* Temporal #sec-temporal.zoneddatetime.prototype.withplaindate */
172 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainDate)
173 /* Temporal #sec-temporal.zoneddatetime.prototype.add */
174 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeAdd)
175 /* Temporal #sec-temporal.zoneddatetime.prototype.subtract */
176 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeSubtract)
177 /* Temporal #sec-temporal.zoneddatetime.prototype.until */
178 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeUntil)
179 /* Temporal #sec-temporal.zoneddatetime.prototype.since */
180 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeSince)
181 /* Temporal #sec-temporal.zoneddatetime.prototype.round */
182 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeRound)
183 /* Temporal #sec-temporal.zoneddatetime.prototype.equals */
184 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEquals)
185 /* Temporal #sec-temporal.zoneddatetime.prototype.tostring */
186 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToString)
187 /* Temporal #sec-temporal.zonedddatetimeprototype.tojson */
188 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToJSON)
189 /* Temporal #sec-temporal.zoneddatetime.prototype.startofday */
190 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeStartOfDay)
191 /* Temporal #sec-temporal.zoneddatetime.prototype.toinstant */
192 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToInstant)
193 /* Temporal #sec-temporal.zoneddatetime.prototype.toplaindate */
194 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToPlainDate)
195 /* Temporal #sec-temporal.zoneddatetime.prototype.toplaintime */
196 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToPlainTime)
197 /* Temporal #sec-temporal.zoneddatetime.prototype.toplaindatetime */
198 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToPlainDateTime)
199
200 /* Temporal.Duration */
201 /* Temporal #sec-temporal.duration.from */
202 TO_BE_IMPLEMENTED(TemporalDurationFrom)
203 /* Temporal #sec-temporal.duration.compare */
204 TO_BE_IMPLEMENTED(TemporalDurationCompare)
205 /* Temporal #sec-temporal.duration.prototype.with */
206 TO_BE_IMPLEMENTED(TemporalDurationPrototypeWith)
207 /* Temporal #sec-temporal.duration.prototype.add */
208 TO_BE_IMPLEMENTED(TemporalDurationPrototypeAdd)
209 /* Temporal #sec-temporal.duration.prototype.subtract */
210 TO_BE_IMPLEMENTED(TemporalDurationPrototypeSubtract)
211 /* Temporal #sec-temporal.duration.prototype.round */
212 TO_BE_IMPLEMENTED(TemporalDurationPrototypeRound)
213 /* Temporal #sec-temporal.duration.prototype.total */
214 TO_BE_IMPLEMENTED(TemporalDurationPrototypeTotal)
215 /* Temporal #sec-temporal.duration.prototype.tostring */
216 TO_BE_IMPLEMENTED(TemporalDurationPrototypeToString)
217 /* Temporal #sec-temporal.duration.tojson */
218 TO_BE_IMPLEMENTED(TemporalDurationPrototypeToJSON)
219
220 /* Temporal.Instant */
221 /* Temporal #sec-temporal.instant.compare */
222 TO_BE_IMPLEMENTED(TemporalInstantCompare)
223 /* Temporal #sec-temporal.instant.prototype.add */
224 TO_BE_IMPLEMENTED(TemporalInstantPrototypeAdd)
225 /* Temporal #sec-temporal.instant.prototype.subtract */
226 TO_BE_IMPLEMENTED(TemporalInstantPrototypeSubtract)
227 /* Temporal #sec-temporal.instant.prototype.until */
228 TO_BE_IMPLEMENTED(TemporalInstantPrototypeUntil)
229 /* Temporal #sec-temporal.instant.prototype.since */
230 TO_BE_IMPLEMENTED(TemporalInstantPrototypeSince)
231 /* Temporal #sec-temporal.instant.prototype.round */
232 TO_BE_IMPLEMENTED(TemporalInstantPrototypeRound)
233 /* Temporal #sec-temporal.instant.prototype.equals */
234 TO_BE_IMPLEMENTED(TemporalInstantPrototypeEquals)
235 /* Temporal #sec-temporal.instant.prototype.tostring */
236 TO_BE_IMPLEMENTED(TemporalInstantPrototypeToString)
237 /* Temporal #sec-temporal.instant.tojson */
238 TO_BE_IMPLEMENTED(TemporalInstantPrototypeToJSON)
239 /* Temporal #sec-temporal.instant.prototype.tozoneddatetime */
240 TO_BE_IMPLEMENTED(TemporalInstantPrototypeToZonedDateTime)
241 /* Temporal #sec-temporal.instant.prototype.tozoneddatetimeiso */
242 TO_BE_IMPLEMENTED(TemporalInstantPrototypeToZonedDateTimeISO)
243
244 /* Temporal.PlainYearMonth */
245 /* Temporal #sec-temporal.plainyearmonth.from */
246 TO_BE_IMPLEMENTED(TemporalPlainYearMonthFrom)
247 /* Temporal #sec-temporal.plainyearmonth.compare */
248 TO_BE_IMPLEMENTED(TemporalPlainYearMonthCompare)
249 /* Temporal #sec-temporal.plainyearmonth.prototype.with */
250 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeWith)
251 /* Temporal #sec-temporal.plainyearmonth.prototype.add */
252 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeAdd)
253 /* Temporal #sec-temporal.plainyearmonth.prototype.subtract */
254 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeSubtract)
255 /* Temporal #sec-temporal.plainyearmonth.prototype.until */
256 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeUntil)
257 /* Temporal #sec-temporal.plainyearmonth.prototype.since */
258 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeSince)
259 /* Temporal #sec-temporal.plainyearmonth.prototype.equals */
260 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeEquals)
261 /* Temporal #sec-temporal.plainyearmonth.tostring */
262 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToString)
263 /* Temporal #sec-temporal.plainyearmonth.tojson */
264 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToJSON)
265 /* Temporal #sec-temporal.plainyearmonth.prototype.toplaindate */
266 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToPlainDate)
267
268 /* Temporal.PlainMonthDay */
269 /* Temporal #sec-temporal.plainmonthday.from */
270 TO_BE_IMPLEMENTED(TemporalPlainMonthDayFrom)
271
272 /* There is no compare for PlainMonthDay. See
273 * https://github.com/tc39/proposal-temporal/issues/1547 */
274
275 /* Temporal #sec-temporal.plainmonthday.prototype.with */
276 TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeWith)
277 /* Temporal #sec-temporal.plainmonthday.prototype.equals */
278 TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeEquals)
279 /* Temporal #sec-temporal.plainmonthday.prototype.tostring */
280 TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToString)
281 /* Temporal #sec-temporal.plainmonthday.tojson */
282 TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToJSON)
283 /* Temporal #sec-temporal.plainmonthday.prototype.toplaindate */
284 TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToPlainDate)
285
286 /* Temporal.TimeZone */
287 /* Temporal #sec-temporal.timezone.prototype.getoffsetnanosecondsfor */
288 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetOffsetNanosecondsFor)
289 /* Temporal #sec-temporal.timezone.prototype.getoffsetstringfor */
290 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetOffsetStringFor)
291 /* Temporal #sec-temporal.timezone.prototype.getplaindatetimefor */
292 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPlainDateTimeFor)
293 /* Temporal #sec-temporal.timezone.prototype.getinstantfor */
294 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetInstantFor)
295 /* Temporal #sec-temporal.timezone.prototype.getpossibleinstantsfor */
296 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPossibleInstantsFor)
297 /* Temporal #sec-temporal.timezone.prototype.getnexttransition */
298 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetNextTransition)
299 /* Temporal #sec-temporal.timezone.prototype.getprevioustransition */
300 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPreviousTransition)
301 /* Temporal #sec-temporal.timezone.prototype.tojson */
302 TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeToJSON)
303
304 /* Temporal.Calendar */
305 /* Temporal #sec-temporal.calendar.prototype.yearmonthfromfields */
306 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeYearMonthFromFields)
307 /* Temporal #sec-temporal.calendar.prototype.monthdayfromfields */
308 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthDayFromFields)
309 /* Temporal #sec-temporal.calendar.prototype.dateadd */
310 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDateAdd)
311 /* Temporal #sec-temporal.calendar.prototype.dateuntil */
312 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDateUntil)
313 /* Temporal #sec-temporal.calendar.prototype.month */
314 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonth)
315 /* Temporal #sec-temporal.calendar.prototype.monthcode */
316 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthCode)
317 /* Temporal #sec-temporal.calendar.prototype.day */
318 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDay)
319 /* Temporal #sec-temporal.calendar.prototype.weekofyear */
320 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeWeekOfYear)
321 /* Temporal #sec-temporal.calendar.prototype.tojson */
322 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeToJSON)
323
324 // to be switch to TFJ later
325 /* Temporal #sec-temporal.calendar.prototype.fields */
326 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeFields)
327
328 #ifdef V8_INTL_SUPPORT
329 /* Temporal */
330 /* Temporal #sec-temporal.calendar.prototype.era */
331 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeEra)
332 /* Temporal #sec-temporal.calendar.prototype.erayear */
333 TO_BE_IMPLEMENTED(TemporalCalendarPrototypeEraYear)
334 /* Temporal #sec-temporal.duration.prototype.tolocalestring */
335 TO_BE_IMPLEMENTED(TemporalDurationPrototypeToLocaleString)
336 /* Temporal #sec-temporal.instant.prototype.tolocalestring */
337 TO_BE_IMPLEMENTED(TemporalInstantPrototypeToLocaleString)
338 /* Temporal #sec-temporal.plaindate.prototype.tolocalestring */
339 TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToLocaleString)
340 /* Temporal #sec-temporal.plaindatetime.prototype.tolocalestring */
341 TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString)
342 /* Temporal #sec-temporal.plainmonthday.prototype.tolocalestring */
343 TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToLocaleString)
344 /* Temporal #sec-temporal.plaintime.prototype.tolocalestring */
345 TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToLocaleString)
346 /* Temporal #sec-temporal.plainyearmonth.prototype.tolocalestring */
347 TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToLocaleString)
348 /* Temporal #sec-get-temporal.zoneddatetime.prototype.era */
349 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEra)
350 /* Temporal #sec-get-temporal.zoneddatetime.prototype.erayear */
351 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEraYear)
352 /* Temporal #sec-temporal.zoneddatetime.prototype.tolocalestring */
353 TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToLocaleString)
354 #endif // V8_INTL_SUPPORT
355
356 #define TEMPORAL_CONSTRUCTOR1(T) \
357 BUILTIN(Temporal##T##Constructor) { \
358 HandleScope scope(isolate); \
359 RETURN_RESULT_OR_FAILURE( \
360 isolate, \
361 JSTemporal##T::Constructor(isolate, args.target(), args.new_target(), \
362 args.atOrUndefined(isolate, 1))); \
363 }
364
365 #define TEMPORAL_ID_BY_TO_STRING(T) \
366 BUILTIN(Temporal##T##PrototypeId) { \
367 HandleScope scope(isolate); \
368 Handle<String> id; \
369 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
370 isolate, id, Object::ToString(isolate, args.receiver())); \
371 return *id; \
372 }
373
374 #define TEMPORAL_TO_STRING(T) \
375 BUILTIN(Temporal##T##PrototypeToString) { \
376 HandleScope scope(isolate); \
377 const char* method = "Temporal." #T ".prototype.toString"; \
378 CHECK_RECEIVER(JSTemporal##T, t, method); \
379 Handle<Object> ret; \
380 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
381 isolate, ret, JSTemporal##T::ToString(isolate, t, method)); \
382 return *ret; \
383 }
384
385 #define TEMPORAL_PROTOTYPE_METHOD0(T, METHOD, name) \
386 BUILTIN(Temporal##T##Prototype##METHOD) { \
387 HandleScope scope(isolate); \
388 const char* method = "Temporal." #T ".prototype." #name; \
389 CHECK_RECEIVER(JSTemporal##T, obj, method); \
390 RETURN_RESULT_OR_FAILURE(isolate, JSTemporal##T ::METHOD(isolate, obj)); \
391 }
392
393 #define TEMPORAL_PROTOTYPE_METHOD1(T, METHOD, name) \
394 BUILTIN(Temporal##T##Prototype##METHOD) { \
395 HandleScope scope(isolate); \
396 const char* method = "Temporal." #T ".prototype." #name; \
397 CHECK_RECEIVER(JSTemporal##T, obj, method); \
398 RETURN_RESULT_OR_FAILURE( \
399 isolate, \
400 JSTemporal##T ::METHOD(isolate, obj, args.atOrUndefined(isolate, 1))); \
401 }
402
403 #define TEMPORAL_PROTOTYPE_METHOD2(T, METHOD, name) \
404 BUILTIN(Temporal##T##Prototype##METHOD) { \
405 HandleScope scope(isolate); \
406 const char* method = "Temporal." #T ".prototype." #name; \
407 CHECK_RECEIVER(JSTemporal##T, obj, method); \
408 RETURN_RESULT_OR_FAILURE( \
409 isolate, \
410 JSTemporal##T ::METHOD(isolate, obj, args.atOrUndefined(isolate, 1), \
411 args.atOrUndefined(isolate, 2))); \
412 }
413
414 #define TEMPORAL_PROTOTYPE_METHOD3(T, METHOD, name) \
415 BUILTIN(Temporal##T##Prototype##METHOD) { \
416 HandleScope scope(isolate); \
417 const char* method = "Temporal." #T ".prototype." #name; \
418 CHECK_RECEIVER(JSTemporal##T, obj, method); \
419 RETURN_RESULT_OR_FAILURE( \
420 isolate, \
421 JSTemporal##T ::METHOD(isolate, obj, args.atOrUndefined(isolate, 1), \
422 args.atOrUndefined(isolate, 2), \
423 args.atOrUndefined(isolate, 3))); \
424 }
425
426 #define TEMPORAL_METHOD2(T, METHOD) \
427 BUILTIN(Temporal##T##METHOD) { \
428 HandleScope scope(isolate); \
429 RETURN_RESULT_OR_FAILURE( \
430 isolate, \
431 JSTemporal##T ::METHOD(isolate, args.atOrUndefined(isolate, 1), \
432 args.atOrUndefined(isolate, 2))); \
433 }
434
435 #define TEMPORAL_VALUE_OF(T) \
436 BUILTIN(Temporal##T##PrototypeValueOf) { \
437 HandleScope scope(isolate); \
438 THROW_NEW_ERROR_RETURN_FAILURE( \
439 isolate, NewTypeError(MessageTemplate::kDoNotUse, \
440 isolate->factory()->NewStringFromAsciiChecked( \
441 "Temporal." #T ".prototype.valueOf"), \
442 isolate->factory()->NewStringFromAsciiChecked( \
443 "use Temporal." #T \
444 ".prototype.compare for comparison."))); \
445 }
446
447 #define TEMPORAL_GET_SMI(T, METHOD, field) \
448 BUILTIN(Temporal##T##Prototype##METHOD) { \
449 HandleScope scope(isolate); \
450 const char* method = "get Temporal." #T ".prototype." #field; \
451 CHECK_RECEIVER(JSTemporal##T, obj, method); \
452 return Smi::FromInt(obj->field()); \
453 }
454
455 #define TEMPORAL_METHOD1(T, METHOD) \
456 BUILTIN(Temporal##T##METHOD) { \
457 HandleScope scope(isolate); \
458 RETURN_RESULT_OR_FAILURE( \
459 isolate, \
460 JSTemporal##T ::METHOD(isolate, args.atOrUndefined(isolate, 1))); \
461 }
462
463 #define TEMPORAL_GET(T, METHOD, field) \
464 BUILTIN(Temporal##T##Prototype##METHOD) { \
465 HandleScope scope(isolate); \
466 const char* method = "get Temporal." #T ".prototype." #field; \
467 CHECK_RECEIVER(JSTemporal##T, obj, method); \
468 return obj->field(); \
469 }
470
471 #define TEMPORAL_GET_NUMBER_AFTER_DIVID(T, M, field, scale, name) \
472 BUILTIN(Temporal##T##Prototype##M) { \
473 HandleScope scope(isolate); \
474 const char* method = "get Temporal." #T ".prototype." #name; \
475 CHECK_RECEIVER(JSTemporal##T, handle, method); \
476 Handle<BigInt> value; \
477 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
478 isolate, value, \
479 BigInt::Divide(isolate, Handle<BigInt>(handle->field(), isolate), \
480 BigInt::FromUint64(isolate, scale))); \
481 Handle<Object> number = BigInt::ToNumber(isolate, value); \
482 DCHECK(std::isfinite(number->Number())); \
483 return *number; \
484 }
485
486 #define TEMPORAL_GET_BIGINT_AFTER_DIVID(T, M, field, scale, name) \
487 BUILTIN(Temporal##T##Prototype##M) { \
488 HandleScope scope(isolate); \
489 const char* method = "get Temporal." #T ".prototype." #name; \
490 CHECK_RECEIVER(JSTemporal##T, handle, method); \
491 Handle<BigInt> value; \
492 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
493 isolate, value, \
494 BigInt::Divide(isolate, Handle<BigInt>(handle->field(), isolate), \
495 BigInt::FromUint64(isolate, scale))); \
496 return *value; \
497 }
498
499 #define TEMPORAL_GET_BY_FORWARD_CALENDAR(T, METHOD, name) \
500 BUILTIN(Temporal##T##Prototype##METHOD) { \
501 HandleScope scope(isolate); \
502 const char* method = "get Temporal." #T ".prototype." #name; \
503 CHECK_RECEIVER(JSTemporal##T, temporal_date, method); \
504 Handle<JSReceiver> calendar = handle(temporal_date->calendar(), isolate); \
505 RETURN_RESULT_OR_FAILURE(isolate, temporal::Calendar##METHOD( \
506 isolate, calendar, temporal_date)); \
507 }
508
509 #define TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(T, METHOD, name) \
510 BUILTIN(Temporal##T##Prototype##METHOD) { \
511 HandleScope scope(isolate); \
512 const char* method = "get Temporal." #T ".prototype." #name; \
513 /* 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporal \
514 * #T]]). */ \
515 CHECK_RECEIVER(JSTemporal##T, date_like, method); \
516 /* 3. Let calendar be temporalDate.[[Calendar]]. */ \
517 Handle<JSReceiver> calendar = handle(date_like->calendar(), isolate); \
518 /* 2. Return ? Invoke(calendar, "name", « dateLike »). */ \
519 RETURN_RESULT_OR_FAILURE( \
520 isolate, temporal::InvokeCalendarMethod( \
521 isolate, calendar, isolate->factory()->name##_string(), \
522 date_like)); \
523 }
524
525 // Now
526 TEMPORAL_NOW0(TimeZone)
527 TEMPORAL_NOW0(Instant)
528 TEMPORAL_NOW2(PlainDateTime)
529 TEMPORAL_NOW_ISO1(PlainDateTime)
530 TEMPORAL_NOW2(PlainDate)
531 TEMPORAL_NOW_ISO1(PlainDate)
532
533 // There is NO Temporal.now.plainTime
534 // See https://github.com/tc39/proposal-temporal/issues/1540
535 TEMPORAL_NOW_ISO1(PlainTime)
536 TEMPORAL_NOW2(ZonedDateTime)
537 TEMPORAL_NOW_ISO1(ZonedDateTime)
538
539 // PlainDate
540 BUILTIN(TemporalPlainDateConstructor) {
541 HandleScope scope(isolate);
542 RETURN_RESULT_OR_FAILURE(
543 isolate, JSTemporalPlainDate::Constructor(
544 isolate, args.target(), args.new_target(),
545 args.atOrUndefined(isolate, 1), // iso_year
546 args.atOrUndefined(isolate, 2), // iso_month
547 args.atOrUndefined(isolate, 3), // iso_day
548 args.atOrUndefined(isolate, 4))); // calendar_like
549 }
TEMPORAL_METHOD2(PlainDate,From)550 TEMPORAL_METHOD2(PlainDate, From)
551 TEMPORAL_GET(PlainDate, Calendar, calendar)
552 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Year, year)
553 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Month, month)
554 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, MonthCode, monthCode)
555 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Day, day)
556 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DayOfWeek, dayOfWeek)
557 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DayOfYear, dayOfYear)
558 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, WeekOfYear, weekOfYear)
559 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInWeek, daysInWeek)
560 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInMonth, daysInMonth)
561 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInYear, daysInYear)
562 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, MonthsInYear, monthsInYear)
563 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, InLeapYear, inLeapYear)
564 TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
565 TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
566 TEMPORAL_VALUE_OF(PlainDate)
567
568 // PlainTime
569 BUILTIN(TemporalPlainTimeConstructor) {
570 HandleScope scope(isolate);
571 RETURN_RESULT_OR_FAILURE(isolate,
572 JSTemporalPlainTime::Constructor(
573 isolate, args.target(), args.new_target(),
574 args.atOrUndefined(isolate, 1), // hour
575 args.atOrUndefined(isolate, 2), // minute
576 args.atOrUndefined(isolate, 3), // second
577 args.atOrUndefined(isolate, 4), // millisecond
578 args.atOrUndefined(isolate, 5), // microsecond
579 args.atOrUndefined(isolate, 6))); // nanosecond
580 }
TEMPORAL_GET(PlainTime,Calendar,calendar)581 TEMPORAL_GET(PlainTime, Calendar, calendar)
582 TEMPORAL_GET_SMI(PlainTime, Hour, iso_hour)
583 TEMPORAL_GET_SMI(PlainTime, Minute, iso_minute)
584 TEMPORAL_GET_SMI(PlainTime, Second, iso_second)
585 TEMPORAL_GET_SMI(PlainTime, Millisecond, iso_millisecond)
586 TEMPORAL_GET_SMI(PlainTime, Microsecond, iso_microsecond)
587 TEMPORAL_GET_SMI(PlainTime, Nanosecond, iso_nanosecond)
588 TEMPORAL_METHOD2(PlainTime, From)
589 TEMPORAL_PROTOTYPE_METHOD0(PlainTime, GetISOFields, getISOFields)
590 TEMPORAL_VALUE_OF(PlainTime)
591
592 // PlainDateTime
593 BUILTIN(TemporalPlainDateTimeConstructor) {
594 HandleScope scope(isolate);
595 RETURN_RESULT_OR_FAILURE(
596 isolate, JSTemporalPlainDateTime::Constructor(
597 isolate, args.target(), args.new_target(),
598 args.atOrUndefined(isolate, 1), // iso_year
599 args.atOrUndefined(isolate, 2), // iso_month
600 args.atOrUndefined(isolate, 3), // iso_day
601 args.atOrUndefined(isolate, 4), // hour
602 args.atOrUndefined(isolate, 5), // minute
603 args.atOrUndefined(isolate, 6), // second
604 args.atOrUndefined(isolate, 7), // millisecond
605 args.atOrUndefined(isolate, 8), // microsecond
606 args.atOrUndefined(isolate, 9), // nanosecond
607 args.atOrUndefined(isolate, 10))); // calendar_like
608 }
TEMPORAL_GET(PlainDateTime,Calendar,calendar)609 TEMPORAL_GET(PlainDateTime, Calendar, calendar)
610 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Year, year)
611 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Month, month)
612 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, MonthCode, monthCode)
613 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Day, day)
614 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DayOfWeek, dayOfWeek)
615 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DayOfYear, dayOfYear)
616 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, WeekOfYear, weekOfYear)
617 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInWeek, daysInWeek)
618 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInMonth, daysInMonth)
619 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInYear, daysInYear)
620 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, MonthsInYear,
621 monthsInYear)
622 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, InLeapYear, inLeapYear)
623 TEMPORAL_PROTOTYPE_METHOD1(PlainDateTime, WithCalendar, withCalendar)
624 TEMPORAL_GET_SMI(PlainDateTime, Hour, iso_hour)
625 TEMPORAL_GET_SMI(PlainDateTime, Minute, iso_minute)
626 TEMPORAL_GET_SMI(PlainDateTime, Second, iso_second)
627 TEMPORAL_GET_SMI(PlainDateTime, Millisecond, iso_millisecond)
628 TEMPORAL_GET_SMI(PlainDateTime, Microsecond, iso_microsecond)
629 TEMPORAL_GET_SMI(PlainDateTime, Nanosecond, iso_nanosecond)
630 TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields)
631 TEMPORAL_VALUE_OF(PlainDateTime)
632
633 // PlainYearMonth
634 BUILTIN(TemporalPlainYearMonthConstructor) {
635 HandleScope scope(isolate);
636 RETURN_RESULT_OR_FAILURE(
637 isolate, JSTemporalPlainYearMonth::Constructor(
638 isolate, args.target(), args.new_target(),
639 args.atOrUndefined(isolate, 1), // iso_year
640 args.atOrUndefined(isolate, 2), // iso_month
641 args.atOrUndefined(isolate, 3), // calendar_like
642 args.atOrUndefined(isolate, 4))); // reference_iso_day
643 }
TEMPORAL_GET(PlainYearMonth,Calendar,calendar)644 TEMPORAL_GET(PlainYearMonth, Calendar, calendar)
645 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, Year, year)
646 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, Month, month)
647 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, MonthCode, monthCode)
648 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, DaysInYear, daysInYear)
649 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, DaysInMonth, daysInMonth)
650 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, MonthsInYear,
651 monthsInYear)
652 TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, InLeapYear, inLeapYear)
653 TEMPORAL_PROTOTYPE_METHOD0(PlainYearMonth, GetISOFields, getISOFields)
654 TEMPORAL_VALUE_OF(PlainYearMonth)
655
656 // PlainMonthDay
657 BUILTIN(TemporalPlainMonthDayConstructor) {
658 HandleScope scope(isolate);
659 RETURN_RESULT_OR_FAILURE(
660 isolate, JSTemporalPlainMonthDay::Constructor(
661 isolate, args.target(), args.new_target(),
662 args.atOrUndefined(isolate, 1), // iso_month
663 args.atOrUndefined(isolate, 2), // iso_day
664 args.atOrUndefined(isolate, 3), // calendar_like
665 args.atOrUndefined(isolate, 4))); // reference_iso_year
666 }
TEMPORAL_GET(PlainMonthDay,Calendar,calendar)667 TEMPORAL_GET(PlainMonthDay, Calendar, calendar)
668 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainMonthDay, MonthCode, monthCode)
669 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainMonthDay, Day, day)
670 TEMPORAL_PROTOTYPE_METHOD0(PlainMonthDay, GetISOFields, getISOFields)
671 TEMPORAL_VALUE_OF(PlainMonthDay)
672
673 // ZonedDateTime
674
675 #define TEMPORAL_ZONED_DATE_TIME_GET_PREPARE(M) \
676 HandleScope scope(isolate); \
677 const char* method = "get Temporal.ZonedDateTime.prototype." #M; \
678 /* 1. Let zonedDateTime be the this value. */ \
679 /* 2. Perform ? RequireInternalSlot(zonedDateTime, */ \
680 /* [[InitializedTemporalZonedDateTime]]). */ \
681 CHECK_RECEIVER(JSTemporalZonedDateTime, zoned_date_time, method); \
682 /* 3. Let timeZone be zonedDateTime.[[TimeZone]]. */ \
683 Handle<JSReceiver> time_zone = \
684 handle(zoned_date_time->time_zone(), isolate); \
685 /* 4. Let instant be ? */ \
686 /* CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]). */ \
687 Handle<JSTemporalInstant> instant; \
688 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
689 isolate, instant, \
690 temporal::CreateTemporalInstant( \
691 isolate, Handle<BigInt>(zoned_date_time->nanoseconds(), isolate))); \
692 /* 5. Let calendar be zonedDateTime.[[Calendar]]. */ \
693 Handle<JSReceiver> calendar = handle(zoned_date_time->calendar(), isolate); \
694 /* 6. Let temporalDateTime be ? */ \
695 /* BuiltinTimeZoneGetPlainDateTimeFor(timeZone, */ \
696 /* instant, calendar). */ \
697 Handle<JSTemporalPlainDateTime> temporal_date_time; \
698 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( \
699 isolate, temporal_date_time, \
700 temporal::BuiltinTimeZoneGetPlainDateTimeFor( \
701 isolate, time_zone, instant, calendar, method));
702
703 #define TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(M, field) \
704 BUILTIN(TemporalZonedDateTimePrototype##M) { \
705 TEMPORAL_ZONED_DATE_TIME_GET_PREPARE(M) \
706 /* 7. Return (temporalDateTime.[[ #field ]]). */ \
707 return Smi::FromInt(temporal_date_time->field()); \
708 }
709
710 BUILTIN(TemporalZonedDateTimeConstructor) {
711 HandleScope scope(isolate);
712 RETURN_RESULT_OR_FAILURE(
713 isolate, JSTemporalZonedDateTime::Constructor(
714 isolate, args.target(), args.new_target(),
715 args.atOrUndefined(isolate, 1), // epoch_nanoseconds
716 args.atOrUndefined(isolate, 2), // time_zone_like
717 args.atOrUndefined(isolate, 3))); // calendar_like
718 }
TEMPORAL_GET(ZonedDateTime,Calendar,calendar)719 TEMPORAL_GET(ZonedDateTime, Calendar, calendar)
720 TEMPORAL_GET(ZonedDateTime, TimeZone, time_zone)
721 TEMPORAL_GET(ZonedDateTime, EpochNanoseconds, nanoseconds)
722 TEMPORAL_GET_NUMBER_AFTER_DIVID(ZonedDateTime, EpochSeconds, nanoseconds,
723 1000000000, epochSeconds)
724 TEMPORAL_GET_NUMBER_AFTER_DIVID(ZonedDateTime, EpochMilliseconds, nanoseconds,
725 1000000, epochMilliseconds)
726 TEMPORAL_GET_BIGINT_AFTER_DIVID(ZonedDateTime, EpochMicroseconds, nanoseconds,
727 1000, epochMicroseconds)
728 TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Hour, iso_hour)
729 TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Minute, iso_minute)
730 TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Second, iso_second)
731 TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Millisecond,
732 iso_millisecond)
733 TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Microsecond,
734 iso_microsecond)
735 TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Nanosecond,
736 iso_nanosecond)
737 TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar)
738 TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithTimeZone, withTimeZone)
739 TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, ToPlainYearMonth, toPlainYearMonth)
740 TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, ToPlainMonthDay, toPlainMonthDay)
741 TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, GetISOFields, getISOFields)
742 TEMPORAL_VALUE_OF(ZonedDateTime)
743
744 // Duration
745 BUILTIN(TemporalDurationConstructor) {
746 HandleScope scope(isolate);
747 RETURN_RESULT_OR_FAILURE(
748 isolate, JSTemporalDuration::Constructor(
749 isolate, args.target(), args.new_target(),
750 args.atOrUndefined(isolate, 1), // years
751 args.atOrUndefined(isolate, 2), // months
752 args.atOrUndefined(isolate, 3), // weeks
753 args.atOrUndefined(isolate, 4), // days
754 args.atOrUndefined(isolate, 5), // hours
755 args.atOrUndefined(isolate, 6), // minutes
756 args.atOrUndefined(isolate, 7), // seconds
757 args.atOrUndefined(isolate, 8), // milliseconds
758 args.atOrUndefined(isolate, 9), // microseconds
759 args.atOrUndefined(isolate, 10))); // nanoseconds
760 }
TEMPORAL_GET(Duration,Years,years)761 TEMPORAL_GET(Duration, Years, years)
762 TEMPORAL_GET(Duration, Months, months)
763 TEMPORAL_GET(Duration, Weeks, weeks)
764 TEMPORAL_GET(Duration, Days, days)
765 TEMPORAL_GET(Duration, Hours, hours)
766 TEMPORAL_GET(Duration, Minutes, minutes)
767 TEMPORAL_GET(Duration, Seconds, seconds)
768 TEMPORAL_GET(Duration, Milliseconds, milliseconds)
769 TEMPORAL_GET(Duration, Microseconds, microseconds)
770 TEMPORAL_GET(Duration, Nanoseconds, nanoseconds)
771 TEMPORAL_PROTOTYPE_METHOD0(Duration, Sign, sign)
772 TEMPORAL_PROTOTYPE_METHOD0(Duration, Blank, blank)
773 TEMPORAL_PROTOTYPE_METHOD0(Duration, Negated, negated)
774 TEMPORAL_PROTOTYPE_METHOD0(Duration, Abs, abs)
775 TEMPORAL_VALUE_OF(Duration)
776
777 // Instant
778 TEMPORAL_CONSTRUCTOR1(Instant)
779 TEMPORAL_METHOD1(Instant, FromEpochSeconds)
780 TEMPORAL_METHOD1(Instant, FromEpochMilliseconds)
781 TEMPORAL_METHOD1(Instant, FromEpochMicroseconds)
782 TEMPORAL_METHOD1(Instant, FromEpochNanoseconds)
783 TEMPORAL_METHOD1(Instant, From)
784 TEMPORAL_VALUE_OF(Instant)
785 TEMPORAL_GET(Instant, EpochNanoseconds, nanoseconds)
786 TEMPORAL_GET_NUMBER_AFTER_DIVID(Instant, EpochSeconds, nanoseconds, 1000000000,
787 epochSeconds)
788 TEMPORAL_GET_NUMBER_AFTER_DIVID(Instant, EpochMilliseconds, nanoseconds,
789 1000000, epochMilliseconds)
790 TEMPORAL_GET_BIGINT_AFTER_DIVID(Instant, EpochMicroseconds, nanoseconds, 1000,
791 epochMicroseconds)
792
793 // Calendar
794 TEMPORAL_CONSTRUCTOR1(Calendar)
795 TEMPORAL_ID_BY_TO_STRING(Calendar)
796 TEMPORAL_PROTOTYPE_METHOD2(Calendar, DateFromFields, dateFromFields)
797 TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInMonth, daysInMonth)
798 TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInWeek, daysInWeek)
799 TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInYear, daysInYear)
800 TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfWeek, dayOfWeek)
801 TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfYear, dayOfYear)
802 TEMPORAL_PROTOTYPE_METHOD1(Calendar, InLeapYear, inLeapYear)
803 TEMPORAL_PROTOTYPE_METHOD2(Calendar, MergeFields, mergeFields)
804 TEMPORAL_PROTOTYPE_METHOD1(Calendar, MonthsInYear, monthsInYear)
805 TEMPORAL_PROTOTYPE_METHOD1(Calendar, Year, year)
806 TEMPORAL_TO_STRING(Calendar)
807 // #sec-temporal.calendar.from
808 BUILTIN(TemporalCalendarFrom) {
809 HandleScope scope(isolate);
810 RETURN_RESULT_OR_FAILURE(isolate, temporal::ToTemporalCalendar(
811 isolate, args.atOrUndefined(isolate, 1),
812 "Temporal.Calendar.from"));
813 }
814
815 // TimeZone
816 TEMPORAL_CONSTRUCTOR1(TimeZone)
TEMPORAL_ID_BY_TO_STRING(TimeZone)817 TEMPORAL_ID_BY_TO_STRING(TimeZone)
818 TEMPORAL_TO_STRING(TimeZone)
819 // #sec-temporal.timezone.from
820 BUILTIN(TemporalTimeZoneFrom) {
821 HandleScope scope(isolate);
822 RETURN_RESULT_OR_FAILURE(isolate, temporal::ToTemporalTimeZone(
823 isolate, args.atOrUndefined(isolate, 1),
824 "Temporal.TimeZone.from"));
825 }
826
827 #ifdef V8_INTL_SUPPORT
828 // get Temporal.*.prototype.era/eraYear
829 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Era, era)
830 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, EraYear, eraYear)
831 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Era, era)
832 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, EraYear, eraYear)
833 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, Era, era)
834 TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, EraYear, eraYear)
835 #endif // V8_INTL_SUPPORT
836 } // namespace internal
837 } // namespace v8
838