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
10namespace v8 {
11namespace 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 */
42TO_BE_IMPLEMENTED(TemporalPlainDateCompare)
43/* Temporal #sec-temporal.plaindate.prototype.toplainyearmonth */
44TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainYearMonth)
45/* Temporal #sec-temporal.plaindate.prototype.toplainmonthday */
46TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainMonthDay)
47/* Temporal #sec-temporal.plaindate.prototype.add */
48TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeAdd)
49/* Temporal #sec-temporal.plaindate.prototype.substract */
50TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSubtract)
51/* Temporal #sec-temporal.plaindate.prototype.with */
52TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeWith)
53/* Temporal #sec-temporal.plaindate.prototype.until */
54TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeUntil)
55/* Temporal #sec-temporal.plaindate.prototype.since */
56TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeSince)
57/* Temporal #sec-temporal.plaindate.prototype.equals */
58TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeEquals)
59/* Temporal #sec-temporal.plaindate.prototype.toplaindatetime */
60TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToPlainDateTime)
61/* Temporal #sec-temporal.plaindate.prototype.tozoneddatetime */
62TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToZonedDateTime)
63/* Temporal #sec-temporal.plaindate.prototype.tostring */
64TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToString)
65/* Temporal #sec-temporal.plaindate.prototype.tojson */
66TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToJSON)
67
68/* Temporal.PlaneTime */
69/* Temporal #sec-temporal.plaintime.compare */
70TO_BE_IMPLEMENTED(TemporalPlainTimeCompare)
71/* Temporal #sec-temporal.plaintime.prototype.add */
72TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeAdd)
73/* Temporal #sec-temporal.plaintime.prototype.subtract */
74TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeSubtract)
75/* Temporal #sec-temporal.plaintime.prototype.with */
76TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeWith)
77/* Temporal #sec-temporal.plaintime.prototype.until */
78TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeUntil)
79/* Temporal #sec-temporal.plaintime.prototype.since */
80TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeSince)
81/* Temporal #sec-temporal.plaintime.prototype.round */
82TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeRound)
83/* Temporal #sec-temporal.plaintime.prototype.equals */
84TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeEquals)
85/* Temporal #sec-temporal.plaintime.prototype.toplaindatetime */
86TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToPlainDateTime)
87/* Temporal #sec-temporal.plaintime.prototype.tozoneddatetime */
88TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToZonedDateTime)
89/* Temporal #sec-temporal.plaintime.prototype.tostring */
90TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToString)
91/* Temporal #sec-temporal.plaindtimeprototype.tojson */
92TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToJSON)
93
94/* Temporal.PlaneDateTime */
95/* Temporal #sec-temporal.plaindatetime.from */
96TO_BE_IMPLEMENTED(TemporalPlainDateTimeFrom)
97/* Temporal #sec-temporal.plaindatetime.compare */
98TO_BE_IMPLEMENTED(TemporalPlainDateTimeCompare)
99/* Temporal #sec-temporal.plaindatetime.prototype.with */
100TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWith)
101/* Temporal #sec-temporal.plaindatetime.prototype.withplainTime */
102TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithPlainTime)
103/* Temporal #sec-temporal.plaindatetime.prototype.withplainDate */
104TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeWithPlainDate)
105/* Temporal #sec-temporal.plaindatetime.prototype.add */
106TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeAdd)
107/* Temporal #sec-temporal.plaindatetime.prototype.subtract */
108TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeSubtract)
109/* Temporal #sec-temporal.plaindatetime.prototype.until */
110TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeUntil)
111/* Temporal #sec-temporal.plaindatetime.prototype.since */
112TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeSince)
113/* Temporal #sec-temporal.plaindatetime.prototype.round */
114TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeRound)
115/* Temporal #sec-temporal.plaindatetime.prototype.equals */
116TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeEquals)
117/* Temporal #sec-temporal.plaindatetime.prototype.tostring */
118TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToString)
119/* Temporal #sec-temporal.plainddatetimeprototype.tojson */
120TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToJSON)
121/* Temporal #sec-temporal.plaindatetime.prototype.tozoneddatetime */
122TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToZonedDateTime)
123/* Temporal #sec-temporal.plaindatetime.prototype.toplaindate */
124TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainDate)
125/* Temporal #sec-temporal.plaindatetime.prototype.toplainyearmonth */
126TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainYearMonth)
127/* Temporal #sec-temporal.plaindatetime.prototype.toplainmonthday */
128TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainMonthDay)
129/* Temporal #sec-temporal.plaindatetime.prototype.toplaintime */
130TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToPlainTime)
131
132/* Temporal.ZonedDateTime */
133/* Temporal #sec-temporal.zoneddatetime.from */
134TO_BE_IMPLEMENTED(TemporalZonedDateTimeFrom)
135/* Temporal #sec-temporal.zoneddatetime.compare */
136TO_BE_IMPLEMENTED(TemporalZonedDateTimeCompare)
137/* Temporal #sec-get-temporal.zoneddatetime.prototype.year */
138TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeYear)
139/* Temporal #sec-get-temporal.zoneddatetime.prototype.month */
140TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeMonth)
141/* Temporal #sec-get-temporal.zoneddatetime.prototype.monthcode */
142TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeMonthCode)
143/* Temporal #sec-get-temporal.zoneddatetime.prototype.day */
144TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDay)
145/* Temporal #sec-get-temporal.zoneddatetime.prototype.dayofweek */
146TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDayOfWeek)
147/* Temporal #sec-get-temporal.zoneddatetime.prototype.dayofyear */
148TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDayOfYear)
149/* Temporal #sec-get-temporal.zoneddatetime.prototype.weekofyear */
150TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWeekOfYear)
151/* Temporal #sec-get-temporal.zoneddatetime.prototype.hoursinday */
152TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeHoursInDay)
153/* Temporal #sec-get-temporal.zoneddatetime.prototype.daysinweek */
154TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDaysInWeek)
155/* Temporal #sec-get-temporal.zoneddatetime.prototype.daysinmonth */
156TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDaysInMonth)
157/* Temporal #sec-get-temporal.zoneddatetime.prototype.daysinyear */
158TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeDaysInYear)
159/* Temporal #sec-get-temporal.zoneddatetime.prototype.monthsinyear */
160TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeMonthsInYear)
161/* Temporal #sec-get-temporal.zoneddatetime.prototype.inleapyear */
162TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeInLeapYear)
163/* Temporal #sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds */
164TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeOffsetNanoseconds)
165/* Temporal #sec-get-temporal.zoneddatetime.prototype.offset */
166TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeOffset)
167/* Temporal #sec-temporal.zoneddatetime.prototype.with */
168TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWith)
169/* Temporal #sec-temporal.zoneddatetime.prototype.withplaintime */
170TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainTime)
171/* Temporal #sec-temporal.zoneddatetime.prototype.withplaindate */
172TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeWithPlainDate)
173/* Temporal #sec-temporal.zoneddatetime.prototype.add */
174TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeAdd)
175/* Temporal #sec-temporal.zoneddatetime.prototype.subtract */
176TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeSubtract)
177/* Temporal #sec-temporal.zoneddatetime.prototype.until */
178TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeUntil)
179/* Temporal #sec-temporal.zoneddatetime.prototype.since */
180TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeSince)
181/* Temporal #sec-temporal.zoneddatetime.prototype.round */
182TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeRound)
183/* Temporal #sec-temporal.zoneddatetime.prototype.equals */
184TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEquals)
185/* Temporal #sec-temporal.zoneddatetime.prototype.tostring */
186TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToString)
187/* Temporal #sec-temporal.zonedddatetimeprototype.tojson */
188TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToJSON)
189/* Temporal #sec-temporal.zoneddatetime.prototype.startofday */
190TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeStartOfDay)
191/* Temporal #sec-temporal.zoneddatetime.prototype.toinstant */
192TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToInstant)
193/* Temporal #sec-temporal.zoneddatetime.prototype.toplaindate */
194TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToPlainDate)
195/* Temporal #sec-temporal.zoneddatetime.prototype.toplaintime */
196TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToPlainTime)
197/* Temporal #sec-temporal.zoneddatetime.prototype.toplaindatetime */
198TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeToPlainDateTime)
199
200/* Temporal.Duration */
201/* Temporal #sec-temporal.duration.from */
202TO_BE_IMPLEMENTED(TemporalDurationFrom)
203/* Temporal #sec-temporal.duration.compare */
204TO_BE_IMPLEMENTED(TemporalDurationCompare)
205/* Temporal #sec-temporal.duration.prototype.with */
206TO_BE_IMPLEMENTED(TemporalDurationPrototypeWith)
207/* Temporal #sec-temporal.duration.prototype.add */
208TO_BE_IMPLEMENTED(TemporalDurationPrototypeAdd)
209/* Temporal #sec-temporal.duration.prototype.subtract */
210TO_BE_IMPLEMENTED(TemporalDurationPrototypeSubtract)
211/* Temporal #sec-temporal.duration.prototype.round */
212TO_BE_IMPLEMENTED(TemporalDurationPrototypeRound)
213/* Temporal #sec-temporal.duration.prototype.total */
214TO_BE_IMPLEMENTED(TemporalDurationPrototypeTotal)
215/* Temporal #sec-temporal.duration.prototype.tostring */
216TO_BE_IMPLEMENTED(TemporalDurationPrototypeToString)
217/* Temporal #sec-temporal.duration.tojson */
218TO_BE_IMPLEMENTED(TemporalDurationPrototypeToJSON)
219
220/* Temporal.Instant */
221/* Temporal #sec-temporal.instant.compare */
222TO_BE_IMPLEMENTED(TemporalInstantCompare)
223/* Temporal #sec-temporal.instant.prototype.add */
224TO_BE_IMPLEMENTED(TemporalInstantPrototypeAdd)
225/* Temporal #sec-temporal.instant.prototype.subtract */
226TO_BE_IMPLEMENTED(TemporalInstantPrototypeSubtract)
227/* Temporal #sec-temporal.instant.prototype.until */
228TO_BE_IMPLEMENTED(TemporalInstantPrototypeUntil)
229/* Temporal #sec-temporal.instant.prototype.since */
230TO_BE_IMPLEMENTED(TemporalInstantPrototypeSince)
231/* Temporal #sec-temporal.instant.prototype.round */
232TO_BE_IMPLEMENTED(TemporalInstantPrototypeRound)
233/* Temporal #sec-temporal.instant.prototype.equals */
234TO_BE_IMPLEMENTED(TemporalInstantPrototypeEquals)
235/* Temporal #sec-temporal.instant.prototype.tostring */
236TO_BE_IMPLEMENTED(TemporalInstantPrototypeToString)
237/* Temporal #sec-temporal.instant.tojson */
238TO_BE_IMPLEMENTED(TemporalInstantPrototypeToJSON)
239/* Temporal #sec-temporal.instant.prototype.tozoneddatetime */
240TO_BE_IMPLEMENTED(TemporalInstantPrototypeToZonedDateTime)
241/* Temporal #sec-temporal.instant.prototype.tozoneddatetimeiso */
242TO_BE_IMPLEMENTED(TemporalInstantPrototypeToZonedDateTimeISO)
243
244/* Temporal.PlainYearMonth */
245/* Temporal #sec-temporal.plainyearmonth.from */
246TO_BE_IMPLEMENTED(TemporalPlainYearMonthFrom)
247/* Temporal #sec-temporal.plainyearmonth.compare */
248TO_BE_IMPLEMENTED(TemporalPlainYearMonthCompare)
249/* Temporal #sec-temporal.plainyearmonth.prototype.with */
250TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeWith)
251/* Temporal #sec-temporal.plainyearmonth.prototype.add */
252TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeAdd)
253/* Temporal #sec-temporal.plainyearmonth.prototype.subtract */
254TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeSubtract)
255/* Temporal #sec-temporal.plainyearmonth.prototype.until */
256TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeUntil)
257/* Temporal #sec-temporal.plainyearmonth.prototype.since */
258TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeSince)
259/* Temporal #sec-temporal.plainyearmonth.prototype.equals */
260TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeEquals)
261/* Temporal #sec-temporal.plainyearmonth.tostring */
262TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToString)
263/* Temporal #sec-temporal.plainyearmonth.tojson */
264TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToJSON)
265/* Temporal #sec-temporal.plainyearmonth.prototype.toplaindate */
266TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToPlainDate)
267
268/* Temporal.PlainMonthDay */
269/* Temporal #sec-temporal.plainmonthday.from */
270TO_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 */
276TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeWith)
277/* Temporal #sec-temporal.plainmonthday.prototype.equals */
278TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeEquals)
279/* Temporal #sec-temporal.plainmonthday.prototype.tostring */
280TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToString)
281/* Temporal #sec-temporal.plainmonthday.tojson */
282TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToJSON)
283/* Temporal #sec-temporal.plainmonthday.prototype.toplaindate */
284TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToPlainDate)
285
286/* Temporal.TimeZone */
287/* Temporal #sec-temporal.timezone.prototype.getoffsetnanosecondsfor */
288TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetOffsetNanosecondsFor)
289/* Temporal #sec-temporal.timezone.prototype.getoffsetstringfor */
290TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetOffsetStringFor)
291/* Temporal #sec-temporal.timezone.prototype.getplaindatetimefor */
292TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPlainDateTimeFor)
293/* Temporal #sec-temporal.timezone.prototype.getinstantfor */
294TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetInstantFor)
295/* Temporal #sec-temporal.timezone.prototype.getpossibleinstantsfor */
296TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPossibleInstantsFor)
297/* Temporal #sec-temporal.timezone.prototype.getnexttransition */
298TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetNextTransition)
299/* Temporal #sec-temporal.timezone.prototype.getprevioustransition */
300TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeGetPreviousTransition)
301/* Temporal #sec-temporal.timezone.prototype.tojson */
302TO_BE_IMPLEMENTED(TemporalTimeZonePrototypeToJSON)
303
304/* Temporal.Calendar */
305/* Temporal #sec-temporal.calendar.prototype.yearmonthfromfields */
306TO_BE_IMPLEMENTED(TemporalCalendarPrototypeYearMonthFromFields)
307/* Temporal #sec-temporal.calendar.prototype.monthdayfromfields */
308TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthDayFromFields)
309/* Temporal #sec-temporal.calendar.prototype.dateadd */
310TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDateAdd)
311/* Temporal #sec-temporal.calendar.prototype.dateuntil */
312TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDateUntil)
313/* Temporal #sec-temporal.calendar.prototype.month */
314TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonth)
315/* Temporal #sec-temporal.calendar.prototype.monthcode */
316TO_BE_IMPLEMENTED(TemporalCalendarPrototypeMonthCode)
317/* Temporal #sec-temporal.calendar.prototype.day */
318TO_BE_IMPLEMENTED(TemporalCalendarPrototypeDay)
319/* Temporal #sec-temporal.calendar.prototype.weekofyear */
320TO_BE_IMPLEMENTED(TemporalCalendarPrototypeWeekOfYear)
321/* Temporal #sec-temporal.calendar.prototype.tojson */
322TO_BE_IMPLEMENTED(TemporalCalendarPrototypeToJSON)
323
324// to be switch to TFJ later
325/* Temporal #sec-temporal.calendar.prototype.fields */
326TO_BE_IMPLEMENTED(TemporalCalendarPrototypeFields)
327
328#ifdef V8_INTL_SUPPORT
329/* Temporal */
330/* Temporal #sec-temporal.calendar.prototype.era */
331TO_BE_IMPLEMENTED(TemporalCalendarPrototypeEra)
332/* Temporal #sec-temporal.calendar.prototype.erayear */
333TO_BE_IMPLEMENTED(TemporalCalendarPrototypeEraYear)
334/* Temporal #sec-temporal.duration.prototype.tolocalestring */
335TO_BE_IMPLEMENTED(TemporalDurationPrototypeToLocaleString)
336/* Temporal #sec-temporal.instant.prototype.tolocalestring */
337TO_BE_IMPLEMENTED(TemporalInstantPrototypeToLocaleString)
338/* Temporal #sec-temporal.plaindate.prototype.tolocalestring */
339TO_BE_IMPLEMENTED(TemporalPlainDatePrototypeToLocaleString)
340/* Temporal #sec-temporal.plaindatetime.prototype.tolocalestring */
341TO_BE_IMPLEMENTED(TemporalPlainDateTimePrototypeToLocaleString)
342/* Temporal #sec-temporal.plainmonthday.prototype.tolocalestring */
343TO_BE_IMPLEMENTED(TemporalPlainMonthDayPrototypeToLocaleString)
344/* Temporal #sec-temporal.plaintime.prototype.tolocalestring */
345TO_BE_IMPLEMENTED(TemporalPlainTimePrototypeToLocaleString)
346/* Temporal #sec-temporal.plainyearmonth.prototype.tolocalestring */
347TO_BE_IMPLEMENTED(TemporalPlainYearMonthPrototypeToLocaleString)
348/* Temporal #sec-get-temporal.zoneddatetime.prototype.era */
349TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEra)
350/* Temporal #sec-get-temporal.zoneddatetime.prototype.erayear */
351TO_BE_IMPLEMENTED(TemporalZonedDateTimePrototypeEraYear)
352/* Temporal #sec-temporal.zoneddatetime.prototype.tolocalestring */
353TO_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
526TEMPORAL_NOW0(TimeZone)
527TEMPORAL_NOW0(Instant)
528TEMPORAL_NOW2(PlainDateTime)
529TEMPORAL_NOW_ISO1(PlainDateTime)
530TEMPORAL_NOW2(PlainDate)
531TEMPORAL_NOW_ISO1(PlainDate)
532
533// There is NO Temporal.now.plainTime
534// See https://github.com/tc39/proposal-temporal/issues/1540
535TEMPORAL_NOW_ISO1(PlainTime)
536TEMPORAL_NOW2(ZonedDateTime)
537TEMPORAL_NOW_ISO1(ZonedDateTime)
538
539// PlainDate
540BUILTIN(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}
550TEMPORAL_METHOD2(PlainDate, From)
551TEMPORAL_GET(PlainDate, Calendar, calendar)
552TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Year, year)
553TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Month, month)
554TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, MonthCode, monthCode)
555TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Day, day)
556TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DayOfWeek, dayOfWeek)
557TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DayOfYear, dayOfYear)
558TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, WeekOfYear, weekOfYear)
559TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInWeek, daysInWeek)
560TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInMonth, daysInMonth)
561TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, DaysInYear, daysInYear)
562TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, MonthsInYear, monthsInYear)
563TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDate, InLeapYear, inLeapYear)
564TEMPORAL_PROTOTYPE_METHOD1(PlainDate, WithCalendar, withCalendar)
565TEMPORAL_PROTOTYPE_METHOD0(PlainDate, GetISOFields, getISOFields)
566TEMPORAL_VALUE_OF(PlainDate)
567
568// PlainTime
569BUILTIN(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}
581TEMPORAL_GET(PlainTime, Calendar, calendar)
582TEMPORAL_GET_SMI(PlainTime, Hour, iso_hour)
583TEMPORAL_GET_SMI(PlainTime, Minute, iso_minute)
584TEMPORAL_GET_SMI(PlainTime, Second, iso_second)
585TEMPORAL_GET_SMI(PlainTime, Millisecond, iso_millisecond)
586TEMPORAL_GET_SMI(PlainTime, Microsecond, iso_microsecond)
587TEMPORAL_GET_SMI(PlainTime, Nanosecond, iso_nanosecond)
588TEMPORAL_METHOD2(PlainTime, From)
589TEMPORAL_PROTOTYPE_METHOD0(PlainTime, GetISOFields, getISOFields)
590TEMPORAL_VALUE_OF(PlainTime)
591
592// PlainDateTime
593BUILTIN(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}
609TEMPORAL_GET(PlainDateTime, Calendar, calendar)
610TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Year, year)
611TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Month, month)
612TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, MonthCode, monthCode)
613TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Day, day)
614TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DayOfWeek, dayOfWeek)
615TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DayOfYear, dayOfYear)
616TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, WeekOfYear, weekOfYear)
617TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInWeek, daysInWeek)
618TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInMonth, daysInMonth)
619TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, DaysInYear, daysInYear)
620TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, MonthsInYear,
621                                       monthsInYear)
622TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainDateTime, InLeapYear, inLeapYear)
623TEMPORAL_PROTOTYPE_METHOD1(PlainDateTime, WithCalendar, withCalendar)
624TEMPORAL_GET_SMI(PlainDateTime, Hour, iso_hour)
625TEMPORAL_GET_SMI(PlainDateTime, Minute, iso_minute)
626TEMPORAL_GET_SMI(PlainDateTime, Second, iso_second)
627TEMPORAL_GET_SMI(PlainDateTime, Millisecond, iso_millisecond)
628TEMPORAL_GET_SMI(PlainDateTime, Microsecond, iso_microsecond)
629TEMPORAL_GET_SMI(PlainDateTime, Nanosecond, iso_nanosecond)
630TEMPORAL_PROTOTYPE_METHOD0(PlainDateTime, GetISOFields, getISOFields)
631TEMPORAL_VALUE_OF(PlainDateTime)
632
633// PlainYearMonth
634BUILTIN(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}
644TEMPORAL_GET(PlainYearMonth, Calendar, calendar)
645TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, Year, year)
646TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, Month, month)
647TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, MonthCode, monthCode)
648TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, DaysInYear, daysInYear)
649TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, DaysInMonth, daysInMonth)
650TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, MonthsInYear,
651                                       monthsInYear)
652TEMPORAL_GET_BY_INVOKE_CALENDAR_METHOD(PlainYearMonth, InLeapYear, inLeapYear)
653TEMPORAL_PROTOTYPE_METHOD0(PlainYearMonth, GetISOFields, getISOFields)
654TEMPORAL_VALUE_OF(PlainYearMonth)
655
656// PlainMonthDay
657BUILTIN(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}
667TEMPORAL_GET(PlainMonthDay, Calendar, calendar)
668TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainMonthDay, MonthCode, monthCode)
669TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainMonthDay, Day, day)
670TEMPORAL_PROTOTYPE_METHOD0(PlainMonthDay, GetISOFields, getISOFields)
671TEMPORAL_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
710BUILTIN(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}
719TEMPORAL_GET(ZonedDateTime, Calendar, calendar)
720TEMPORAL_GET(ZonedDateTime, TimeZone, time_zone)
721TEMPORAL_GET(ZonedDateTime, EpochNanoseconds, nanoseconds)
722TEMPORAL_GET_NUMBER_AFTER_DIVID(ZonedDateTime, EpochSeconds, nanoseconds,
723                                1000000000, epochSeconds)
724TEMPORAL_GET_NUMBER_AFTER_DIVID(ZonedDateTime, EpochMilliseconds, nanoseconds,
725                                1000000, epochMilliseconds)
726TEMPORAL_GET_BIGINT_AFTER_DIVID(ZonedDateTime, EpochMicroseconds, nanoseconds,
727                                1000, epochMicroseconds)
728TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Hour, iso_hour)
729TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Minute, iso_minute)
730TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Second, iso_second)
731TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Millisecond,
732                                                      iso_millisecond)
733TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Microsecond,
734                                                      iso_microsecond)
735TEMPORAL_ZONED_DATE_TIME_GET_INT_BY_FORWARD_TIME_ZONE(Nanosecond,
736                                                      iso_nanosecond)
737TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithCalendar, withCalendar)
738TEMPORAL_PROTOTYPE_METHOD1(ZonedDateTime, WithTimeZone, withTimeZone)
739TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, ToPlainYearMonth, toPlainYearMonth)
740TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, ToPlainMonthDay, toPlainMonthDay)
741TEMPORAL_PROTOTYPE_METHOD0(ZonedDateTime, GetISOFields, getISOFields)
742TEMPORAL_VALUE_OF(ZonedDateTime)
743
744// Duration
745BUILTIN(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}
761TEMPORAL_GET(Duration, Years, years)
762TEMPORAL_GET(Duration, Months, months)
763TEMPORAL_GET(Duration, Weeks, weeks)
764TEMPORAL_GET(Duration, Days, days)
765TEMPORAL_GET(Duration, Hours, hours)
766TEMPORAL_GET(Duration, Minutes, minutes)
767TEMPORAL_GET(Duration, Seconds, seconds)
768TEMPORAL_GET(Duration, Milliseconds, milliseconds)
769TEMPORAL_GET(Duration, Microseconds, microseconds)
770TEMPORAL_GET(Duration, Nanoseconds, nanoseconds)
771TEMPORAL_PROTOTYPE_METHOD0(Duration, Sign, sign)
772TEMPORAL_PROTOTYPE_METHOD0(Duration, Blank, blank)
773TEMPORAL_PROTOTYPE_METHOD0(Duration, Negated, negated)
774TEMPORAL_PROTOTYPE_METHOD0(Duration, Abs, abs)
775TEMPORAL_VALUE_OF(Duration)
776
777// Instant
778TEMPORAL_CONSTRUCTOR1(Instant)
779TEMPORAL_METHOD1(Instant, FromEpochSeconds)
780TEMPORAL_METHOD1(Instant, FromEpochMilliseconds)
781TEMPORAL_METHOD1(Instant, FromEpochMicroseconds)
782TEMPORAL_METHOD1(Instant, FromEpochNanoseconds)
783TEMPORAL_METHOD1(Instant, From)
784TEMPORAL_VALUE_OF(Instant)
785TEMPORAL_GET(Instant, EpochNanoseconds, nanoseconds)
786TEMPORAL_GET_NUMBER_AFTER_DIVID(Instant, EpochSeconds, nanoseconds, 1000000000,
787                                epochSeconds)
788TEMPORAL_GET_NUMBER_AFTER_DIVID(Instant, EpochMilliseconds, nanoseconds,
789                                1000000, epochMilliseconds)
790TEMPORAL_GET_BIGINT_AFTER_DIVID(Instant, EpochMicroseconds, nanoseconds, 1000,
791                                epochMicroseconds)
792
793// Calendar
794TEMPORAL_CONSTRUCTOR1(Calendar)
795TEMPORAL_ID_BY_TO_STRING(Calendar)
796TEMPORAL_PROTOTYPE_METHOD2(Calendar, DateFromFields, dateFromFields)
797TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInMonth, daysInMonth)
798TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInWeek, daysInWeek)
799TEMPORAL_PROTOTYPE_METHOD1(Calendar, DaysInYear, daysInYear)
800TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfWeek, dayOfWeek)
801TEMPORAL_PROTOTYPE_METHOD1(Calendar, DayOfYear, dayOfYear)
802TEMPORAL_PROTOTYPE_METHOD1(Calendar, InLeapYear, inLeapYear)
803TEMPORAL_PROTOTYPE_METHOD2(Calendar, MergeFields, mergeFields)
804TEMPORAL_PROTOTYPE_METHOD1(Calendar, MonthsInYear, monthsInYear)
805TEMPORAL_PROTOTYPE_METHOD1(Calendar, Year, year)
806TEMPORAL_TO_STRING(Calendar)
807// #sec-temporal.calendar.from
808BUILTIN(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
816TEMPORAL_CONSTRUCTOR1(TimeZone)
817TEMPORAL_ID_BY_TO_STRING(TimeZone)
818TEMPORAL_TO_STRING(TimeZone)
819// #sec-temporal.timezone.from
820BUILTIN(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
829TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, Era, era)
830TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDate, EraYear, eraYear)
831TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, Era, era)
832TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainDateTime, EraYear, eraYear)
833TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, Era, era)
834TEMPORAL_GET_BY_FORWARD_CALENDAR(PlainYearMonth, EraYear, eraYear)
835#endif  // V8_INTL_SUPPORT
836}  // namespace internal
837}  // namespace v8
838