TimeZone.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/DateTimeLexer.h>
  7. #include <LibCrypto/BigInt/UnsignedBigInteger.h>
  8. #include <LibJS/Runtime/AbstractOperations.h>
  9. #include <LibJS/Runtime/Date.h>
  10. #include <LibJS/Runtime/GlobalObject.h>
  11. #include <LibJS/Runtime/Temporal/AbstractOperations.h>
  12. #include <LibJS/Runtime/Temporal/Instant.h>
  13. #include <LibJS/Runtime/Temporal/PlainDateTime.h>
  14. #include <LibJS/Runtime/Temporal/TimeZone.h>
  15. #include <LibJS/Runtime/Temporal/TimeZoneConstructor.h>
  16. #include <LibJS/Runtime/Temporal/ZonedDateTime.h>
  17. namespace JS::Temporal {
  18. // 11 Temporal.TimeZone Objects, https://tc39.es/proposal-temporal/#sec-temporal-timezone-objects
  19. TimeZone::TimeZone(String identifier, Object& prototype)
  20. : Object(prototype)
  21. , m_identifier(move(identifier))
  22. {
  23. }
  24. // 11.1.1 IsValidTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sec-isvalidtimezonename
  25. // NOTE: This is the minimum implementation of IsValidTimeZoneName, supporting only the "UTC" time zone.
  26. bool is_valid_time_zone_name(String const& time_zone)
  27. {
  28. // 1. Assert: Type(timeZone) is String.
  29. // 2. Let tzText be ! StringToCodePoints(timeZone).
  30. // 3. Let tzUpperText be the result of toUppercase(tzText), according to the Unicode Default Case Conversion algorithm.
  31. // 4. Let tzUpper be ! CodePointsToString(tzUpperText).
  32. auto tz_upper = time_zone.to_uppercase();
  33. // 5. If tzUpper and "UTC" are the same sequence of code points, return true.
  34. if (tz_upper == "UTC")
  35. return true;
  36. // 6. Return false.
  37. return false;
  38. }
  39. // 11.1.2 CanonicalizeTimeZoneName ( timeZone ), https://tc39.es/proposal-temporal/#sec-canonicalizetimezonename
  40. // NOTE: This is the minimum implementation of CanonicalizeTimeZoneName, supporting only the "UTC" time zone.
  41. String canonicalize_time_zone_name(String const& time_zone)
  42. {
  43. // 1. Assert: Type(timeZone) is String.
  44. // 2. Assert: ! IsValidTimeZoneName(timeZone) is true.
  45. VERIFY(is_valid_time_zone_name(time_zone));
  46. // 3. Return "UTC".
  47. return "UTC";
  48. }
  49. // 11.1.3 DefaultTimeZone ( ), https://tc39.es/proposal-temporal/#sec-defaulttimezone
  50. // NOTE: This is the minimum implementation of DefaultTimeZone, supporting only the "UTC" time zone.
  51. String default_time_zone()
  52. {
  53. // 1. Return "UTC".
  54. return "UTC";
  55. }
  56. // 11.6.1 ParseTemporalTimeZone ( string ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaltimezone
  57. ThrowCompletionOr<String> parse_temporal_time_zone(GlobalObject& global_object, String const& string)
  58. {
  59. // 1. Assert: Type(string) is String.
  60. // 2. Let result be ? ParseTemporalTimeZoneString(string).
  61. auto result = TRY(parse_temporal_time_zone_string(global_object, string));
  62. // 3. If result.[[Z]] is not undefined, return "UTC".
  63. if (result.z)
  64. return String { "UTC" };
  65. // 4. Return result.[[Name]].
  66. return *result.name;
  67. }
  68. // 11.6.2 CreateTemporalTimeZone ( identifier [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporaltimezone
  69. ThrowCompletionOr<TimeZone*> create_temporal_time_zone(GlobalObject& global_object, String const& identifier, FunctionObject const* new_target)
  70. {
  71. // 1. If newTarget is not present, set it to %Temporal.TimeZone%.
  72. if (!new_target)
  73. new_target = global_object.temporal_time_zone_constructor();
  74. // 2. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.TimeZone.prototype%", « [[InitializedTemporalTimeZone]], [[Identifier]], [[OffsetNanoseconds]] »).
  75. // 3. Set object.[[Identifier]] to identifier.
  76. auto* object = TRY(ordinary_create_from_constructor<TimeZone>(global_object, *new_target, &GlobalObject::temporal_time_zone_prototype, identifier));
  77. // 4. If identifier satisfies the syntax of a TimeZoneNumericUTCOffset (see 13.33), then
  78. if (is_valid_time_zone_numeric_utc_offset_syntax(identifier)) {
  79. // a. Set object.[[OffsetNanoseconds]] to ! ParseTimeZoneOffsetString(identifier).
  80. object->set_offset_nanoseconds(TRY(parse_time_zone_offset_string(global_object, identifier)));
  81. }
  82. // 5. Else,
  83. else {
  84. // a. Assert: ! CanonicalizeTimeZoneName(identifier) is identifier.
  85. VERIFY(canonicalize_time_zone_name(identifier) == identifier);
  86. // b. Set object.[[OffsetNanoseconds]] to undefined.
  87. // NOTE: No-op.
  88. }
  89. // 6. Return object.
  90. return object;
  91. }
  92. // 11.6.3 GetISOPartsFromEpoch ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-getisopartsfromepoch
  93. ISODateTime get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds)
  94. {
  95. // 1. Let remainderNs be remainder(epochNanoseconds, 10^6).
  96. auto remainder_ns_bigint = epoch_nanoseconds.big_integer().divided_by(Crypto::UnsignedBigInteger { 1'000'000 }).remainder;
  97. auto remainder_ns = remainder_ns_bigint.to_base(10).to_int<i64>().value();
  98. // 2. Let epochMilliseconds be (epochNanoseconds − remainderNs) / 10^6.
  99. auto epoch_milliseconds_bigint = epoch_nanoseconds.big_integer().minus(remainder_ns_bigint).divided_by(Crypto::UnsignedBigInteger { 1'000'000 }).quotient;
  100. auto epoch_milliseconds = (double)epoch_milliseconds_bigint.to_base(10).to_int<i64>().value();
  101. // 3. Let year be ! YearFromTime(epochMilliseconds).
  102. auto year = year_from_time(epoch_milliseconds);
  103. // 4. Let month be ! MonthFromTime(epochMilliseconds) + 1.
  104. auto month = static_cast<u8>(month_from_time(epoch_milliseconds) + 1);
  105. // 5. Let day be ! DateFromTime(epochMilliseconds).
  106. auto day = date_from_time(epoch_milliseconds);
  107. // 6. Let hour be ! HourFromTime(epochMilliseconds).
  108. auto hour = hour_from_time(epoch_milliseconds);
  109. // 7. Let minute be ! MinFromTime(epochMilliseconds).
  110. auto minute = min_from_time(epoch_milliseconds);
  111. // 8. Let second be ! SecFromTime(epochMilliseconds).
  112. auto second = sec_from_time(epoch_milliseconds);
  113. // 9. Let millisecond be ! msFromTime(epochMilliseconds).
  114. auto millisecond = ms_from_time(epoch_milliseconds);
  115. // 10. Let microsecond be floor(remainderNs / 1000) modulo 1000.
  116. auto microsecond = static_cast<u16>((remainder_ns / 1000) % 1000);
  117. // 11. Let nanosecond be remainderNs modulo 1000.
  118. auto nanosecond = static_cast<u16>(remainder_ns % 1000);
  119. // 12. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day, [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }.
  120. return { .year = year, .month = month, .day = day, .hour = hour, .minute = minute, .second = second, .millisecond = millisecond, .microsecond = microsecond, .nanosecond = nanosecond };
  121. }
  122. // 11.6.5 GetIANATimeZoneOffsetNanoseconds ( epochNanoseconds, timeZoneIdentifier ), https://tc39.es/proposal-temporal/#sec-temporal-getianatimezoneoffsetnanoseconds
  123. i64 get_iana_time_zone_offset_nanoseconds([[maybe_unused]] BigInt const& epoch_nanoseconds, [[maybe_unused]] String const& time_zone_identifier)
  124. {
  125. // The abstract operation GetIANATimeZoneOffsetNanoseconds is an implementation-defined algorithm that returns an integer representing the offset of the IANA time zone identified by timeZoneIdentifier from UTC, at the instant corresponding to epochNanoseconds.
  126. // Given the same values of epochNanoseconds and timeZoneIdentifier, the result must be the same for the lifetime of the surrounding agent.
  127. // TODO: Implement this
  128. return 0;
  129. }
  130. // https://tc39.es/proposal-temporal/#prod-TimeZoneNumericUTCOffset
  131. static bool parse_time_zone_numeric_utc_offset_syntax(String const& offset_string, StringView& sign, StringView& hours, Optional<StringView>& minutes, Optional<StringView>& seconds, Optional<StringView>& fraction)
  132. {
  133. DateTimeLexer lexer(offset_string);
  134. auto sign_part = lexer.consume_sign();
  135. if (!sign_part.has_value())
  136. return false;
  137. sign = *sign_part;
  138. auto hours_part = lexer.consume_hours();
  139. if (!hours_part.has_value())
  140. return false;
  141. hours = *hours_part;
  142. if (!lexer.tell_remaining())
  143. return true;
  144. auto uses_separator = lexer.consume_specific(':');
  145. minutes = lexer.consume_minutes_or_seconds();
  146. if (!minutes.has_value())
  147. return false;
  148. if (!lexer.tell_remaining())
  149. return true;
  150. if (lexer.consume_specific(':') != uses_separator)
  151. return false;
  152. seconds = lexer.consume_minutes_or_seconds();
  153. if (!seconds.has_value())
  154. return false;
  155. if (!lexer.tell_remaining())
  156. return true;
  157. if (!lexer.consume_specific('.') && !lexer.consume_specific(','))
  158. return false;
  159. fraction = lexer.consume_fractional_seconds();
  160. return fraction.has_value();
  161. }
  162. bool is_valid_time_zone_numeric_utc_offset_syntax(String const& offset_string)
  163. {
  164. StringView discarded;
  165. Optional<StringView> optionally_discarded;
  166. // FIXME: This is very wasteful
  167. return parse_time_zone_numeric_utc_offset_syntax(offset_string, discarded, discarded, optionally_discarded, optionally_discarded, optionally_discarded);
  168. }
  169. // 11.6.8 ParseTimeZoneOffsetString ( offsetString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetimezoneoffsetstring
  170. ThrowCompletionOr<double> parse_time_zone_offset_string(GlobalObject& global_object, String const& offset_string)
  171. {
  172. auto& vm = global_object.vm();
  173. // 1. Assert: Type(offsetString) is String.
  174. // 2. If offsetString does not satisfy the syntax of a TimeZoneNumericUTCOffset (see 13.33), then
  175. // a. Throw a RangeError exception.
  176. // 3. Let sign, hours, minutes, seconds, and fraction be the parts of offsetString produced respectively by the TimeZoneUTCOffsetSign, TimeZoneUTCOffsetHour, TimeZoneUTCOffsetMinute, TimeZoneUTCOffsetSecond, and TimeZoneUTCOffsetFraction productions, or undefined if not present.
  177. StringView sign_part;
  178. StringView hours_part;
  179. Optional<StringView> minutes_part;
  180. Optional<StringView> seconds_part;
  181. Optional<StringView> fraction_part;
  182. auto success = parse_time_zone_numeric_utc_offset_syntax(offset_string, sign_part, hours_part, minutes_part, seconds_part, fraction_part);
  183. if (!success)
  184. return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidFormat, "TimeZone offset");
  185. // 4. If either hours or sign are undefined, throw a RangeError exception.
  186. // NOTE: Both of these checks are always false, due to the handling of Step 2
  187. double sign;
  188. // 5. If sign is the code unit 0x002D (HYPHEN-MINUS) or 0x2212 (MINUS SIGN), then
  189. if (sign_part.is_one_of("-", "\xE2\x88\x92")) {
  190. // a. Set sign to −1.
  191. sign = -1;
  192. }
  193. // 6. Else,
  194. else {
  195. // a. Set sign to 1.
  196. sign = 1;
  197. }
  198. // 7. Set hours to ! ToIntegerOrInfinity(hours).
  199. auto hours = MUST(Value(js_string(vm, hours_part)).to_integer_or_infinity(global_object));
  200. // 8. Set minutes to ! ToIntegerOrInfinity(minutes).
  201. auto minutes = MUST(Value(js_string(vm, minutes_part.value_or(""sv))).to_integer_or_infinity(global_object));
  202. // 9. Set seconds to ! ToIntegerOrInfinity(seconds).
  203. auto seconds = MUST(Value(js_string(vm, seconds_part.value_or(""sv))).to_integer_or_infinity(global_object));
  204. double nanoseconds;
  205. // 10. If fraction is not undefined, then
  206. if (fraction_part.has_value()) {
  207. // a. Set fraction to the string-concatenation of the previous value of fraction and the string "000000000".
  208. auto fraction = String::formatted("{}000000000", *fraction_part);
  209. // b. Let nanoseconds be the String value equal to the substring of fraction consisting of the code units with indices 0 (inclusive) through 9 (exclusive).
  210. // c. Set nanoseconds to ! ToIntegerOrInfinity(nanoseconds).
  211. nanoseconds = MUST(Value(js_string(vm, fraction_part->substring_view(0, 9))).to_integer_or_infinity(global_object));
  212. }
  213. // 11. Else,
  214. else {
  215. // a. Let nanoseconds be 0.
  216. nanoseconds = 0;
  217. }
  218. // 12. Return sign × (((hours × 60 + minutes) × 60 + seconds) × 10^9 + nanoseconds).
  219. return sign * (((hours * 60 + minutes) * 60 + seconds) * 1000000000 + nanoseconds);
  220. }
  221. // 11.6.9 FormatTimeZoneOffsetString ( offsetNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal-formattimezoneoffsetstring
  222. String format_time_zone_offset_string(double offset_nanoseconds)
  223. {
  224. auto offset = static_cast<i64>(offset_nanoseconds);
  225. // 1. Assert: offsetNanoseconds is an integer.
  226. VERIFY(offset == offset_nanoseconds);
  227. StringBuilder builder;
  228. // 2. If offsetNanoseconds ≥ 0, let sign be "+"; otherwise, let sign be "-".
  229. if (offset >= 0)
  230. builder.append('+');
  231. else
  232. builder.append('-');
  233. // 3. Let nanoseconds be abs(offsetNanoseconds) modulo 10^9.
  234. auto nanoseconds = AK::abs(offset) % 1000000000;
  235. // 4. Let seconds be floor(offsetNanoseconds / 10^9) modulo 60.
  236. auto seconds = (offset / 1000000000) % 60;
  237. // 5. Let minutes be floor(offsetNanoseconds / (6 × 10^10)) modulo 60.
  238. auto minutes = (offset / 60000000000) % 60;
  239. // 6. Let hours be floor(offsetNanoseconds / (3.6 × 10^12)).
  240. auto hours = offset / 3600000000000;
  241. // 7. Let h be hours, formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  242. builder.appendff("{:02}", hours);
  243. // 8. Let m be minutes, formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  244. builder.appendff(":{:02}", minutes);
  245. // 9. Let s be seconds, formatted as a two-digit decimal number, padded to the left with a zero if necessary.
  246. // Handled by steps 10 & 11
  247. // 10. If nanoseconds ≠ 0, then
  248. if (nanoseconds != 0) {
  249. // a. Let fraction be nanoseconds, formatted as a nine-digit decimal number, padded to the left with zeroes if necessary.
  250. // b. Set fraction to the longest possible substring of fraction starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
  251. // c. Let post be the string-concatenation of the code unit 0x003A (COLON), s, the code unit 0x002E (FULL STOP), and fraction.
  252. builder.appendff(":{:02}.{:9}", seconds, nanoseconds);
  253. }
  254. // 11. Else if seconds ≠ 0, then
  255. else if (seconds != 0) {
  256. // a. Let post be the string-concatenation of the code unit 0x003A (COLON) and s.
  257. builder.appendff(":{:02}", seconds);
  258. }
  259. // 12. Return the string-concatenation of sign, h, the code unit 0x003A (COLON), m, and post.
  260. return builder.to_string();
  261. }
  262. // 11.6.10 ToTemporalTimeZone ( temporalTimeZoneLike ), https://tc39.es/proposal-temporal/#sec-temporal-totemporaltimezone
  263. ThrowCompletionOr<Object*> to_temporal_time_zone(GlobalObject& global_object, Value temporal_time_zone_like)
  264. {
  265. auto& vm = global_object.vm();
  266. // 1. If Type(temporalTimeZoneLike) is Object, then
  267. if (temporal_time_zone_like.is_object()) {
  268. // a. If temporalTimeZoneLike has an [[InitializedTemporalZonedDateTime]] internal slot, then
  269. if (is<ZonedDateTime>(temporal_time_zone_like.as_object())) {
  270. auto& zoned_date_time = static_cast<ZonedDateTime&>(temporal_time_zone_like.as_object());
  271. // i. Return temporalTimeZoneLike.[[TimeZone]].
  272. return &zoned_date_time.time_zone();
  273. }
  274. // b. If ? HasProperty(temporalTimeZoneLike, "timeZone") is false, return temporalTimeZoneLike.
  275. if (!TRY(temporal_time_zone_like.as_object().has_property(vm.names.timeZone)))
  276. return &temporal_time_zone_like.as_object();
  277. // c. Set temporalTimeZoneLike to ? Get(temporalTimeZoneLike, "timeZone").
  278. temporal_time_zone_like = TRY(temporal_time_zone_like.as_object().get(vm.names.timeZone));
  279. // d. If Type(temporalTimeZoneLike) is Object and ? HasProperty(temporalTimeZoneLike, "timeZone") is false, return temporalTimeZoneLike.
  280. if (temporal_time_zone_like.is_object() && !TRY(temporal_time_zone_like.as_object().has_property(vm.names.timeZone)))
  281. return &temporal_time_zone_like.as_object();
  282. }
  283. // 2. Let identifier be ? ToString(temporalTimeZoneLike).
  284. auto identifier = TRY(temporal_time_zone_like.to_string(global_object));
  285. // 3. Let result be ? ParseTemporalTimeZone(identifier).
  286. auto result = TRY(parse_temporal_time_zone(global_object, identifier));
  287. // 4. Return ? CreateTemporalTimeZone(result).
  288. return TRY(create_temporal_time_zone(global_object, result));
  289. }
  290. // 11.6.11 GetOffsetNanosecondsFor ( timeZone, instant ), https://tc39.es/proposal-temporal/#sec-temporal-getoffsetnanosecondsfor
  291. ThrowCompletionOr<double> get_offset_nanoseconds_for(GlobalObject& global_object, Value time_zone, Instant& instant)
  292. {
  293. auto& vm = global_object.vm();
  294. // 1. Let getOffsetNanosecondsFor be ? GetMethod(timeZone, "getOffsetNanosecondsFor").
  295. auto* get_offset_nanoseconds_for = TRY(time_zone.get_method(global_object, vm.names.getOffsetNanosecondsFor));
  296. // 2. If getOffsetNanosecondsFor is undefined, set getOffsetNanosecondsFor to %Temporal.TimeZone.prototype.getOffsetNanosecondsFor%.
  297. if (!get_offset_nanoseconds_for)
  298. get_offset_nanoseconds_for = global_object.temporal_time_zone_prototype_get_offset_nanoseconds_for_function();
  299. // 3. Let offsetNanoseconds be ? Call(getOffsetNanosecondsFor, timeZone, « instant »).
  300. auto offset_nanoseconds_value = TRY(vm.call(*get_offset_nanoseconds_for, time_zone, &instant));
  301. // 4. If Type(offsetNanoseconds) is not Number, throw a TypeError exception.
  302. if (!offset_nanoseconds_value.is_number())
  303. return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, "Offset nanoseconds value", "number");
  304. // 5. If ! IsIntegralNumber(offsetNanoseconds) is false, throw a RangeError exception.
  305. if (!offset_nanoseconds_value.is_integral_number())
  306. return vm.throw_completion<RangeError>(global_object, ErrorType::IsNotAn, "Offset nanoseconds value", "integral number");
  307. // 6. Set offsetNanoseconds to ℝ(offsetNanoseconds).
  308. auto offset_nanoseconds = offset_nanoseconds_value.as_double();
  309. // 7. If abs(offsetNanoseconds) > 86400 × 10^9, throw a RangeError exception.
  310. if (fabs(offset_nanoseconds) > 86400000000000.0)
  311. return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidOffsetNanosecondsValue);
  312. // 8. Return offsetNanoseconds.
  313. return offset_nanoseconds;
  314. }
  315. // 11.6.12 BuiltinTimeZoneGetOffsetStringFor ( timeZone, instant ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetoffsetstringfor
  316. ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(GlobalObject& global_object, Value time_zone, Instant& instant)
  317. {
  318. // 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
  319. auto offset_nanoseconds = TRY(get_offset_nanoseconds_for(global_object, time_zone, instant));
  320. // 2. Return ! FormatTimeZoneOffsetString(offsetNanoseconds).
  321. return format_time_zone_offset_string(offset_nanoseconds);
  322. }
  323. // 11.6.13 BuiltinTimeZoneGetPlainDateTimeFor ( timeZone, instant, calendar ), https://tc39.es/proposal-temporal/#sec-temporal-builtintimezonegetplaindatetimefor
  324. ThrowCompletionOr<PlainDateTime*> builtin_time_zone_get_plain_date_time_for(GlobalObject& global_object, Value time_zone, Instant& instant, Object& calendar)
  325. {
  326. // 1. Let offsetNanoseconds be ? GetOffsetNanosecondsFor(timeZone, instant).
  327. auto offset_nanoseconds = TRY(get_offset_nanoseconds_for(global_object, time_zone, instant));
  328. // 2. Let result be ! GetISOPartsFromEpoch(instant.[[Nanoseconds]]).
  329. auto result = get_iso_parts_from_epoch(instant.nanoseconds());
  330. // 3. Set result to ! BalanceISODateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]] + offsetNanoseconds).
  331. result = balance_iso_date_time(result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond + offset_nanoseconds);
  332. // 4. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar).
  333. return create_temporal_date_time(global_object, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, calendar);
  334. }
  335. }