/* * Copyright (c) 2021-2023, Linus Groh * Copyright (c) 2021-2023, Luke Wilde * Copyright (c) 2024, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include #include #include #include #include namespace JS::Temporal { GC_DEFINE_ALLOCATOR(ZonedDateTime); // 6 Temporal.ZonedDateTime Objects, https://tc39.es/proposal-temporal/#sec-temporal-zoneddatetime-objects ZonedDateTime::ZonedDateTime(BigInt const& epoch_nanoseconds, String time_zone, String calendar, Object& prototype) : Object(ConstructWithPrototypeTag::Tag, prototype) , m_epoch_nanoseconds(epoch_nanoseconds) , m_time_zone(move(time_zone)) , m_calendar(move(calendar)) { } void ZonedDateTime::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_epoch_nanoseconds); } // 6.5.1 InterpretISODateTimeOffset ( isoDate, time, offsetBehaviour, offsetNanoseconds, timeZone, disambiguation, offsetOption, matchBehaviour ), https://tc39.es/proposal-temporal/#sec-temporal-interpretisodatetimeoffset ThrowCompletionOr interpret_iso_date_time_offset(VM& vm, ISODate iso_date, Variant const& time_or_start_of_day, OffsetBehavior offset_behavior, double offset_nanoseconds, StringView time_zone, Disambiguation disambiguation, OffsetOption offset_option, MatchBehavior match_behavior) { // 1. If time is START-OF-DAY, then if (time_or_start_of_day.has()) { // a. Assert: offsetBehaviour is WALL. VERIFY(offset_behavior == OffsetBehavior::Wall); // b. Assert: offsetNanoseconds is 0. VERIFY(offset_nanoseconds == 0); // c. Return ? GetStartOfDay(timeZone, isoDate). return TRY(get_start_of_day(vm, time_zone, iso_date)); } auto time = time_or_start_of_day.get