mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
And the simple Temporal.ZonedDateTime.prototype getters, so that the constructed Temporal.ZonedDateTime may actually be validated.
55 lines
1.9 KiB
C++
55 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
|
* Copyright (c) 2024, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Runtime/BigInt.h>
|
|
#include <LibJS/Runtime/Completion.h>
|
|
#include <LibJS/Runtime/Object.h>
|
|
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
|
|
#include <LibJS/Runtime/Temporal/ISORecords.h>
|
|
|
|
namespace JS::Temporal {
|
|
|
|
class ZonedDateTime final : public Object {
|
|
JS_OBJECT(ZonedDateTime, Object);
|
|
GC_DECLARE_ALLOCATOR(ZonedDateTime);
|
|
|
|
public:
|
|
virtual ~ZonedDateTime() override = default;
|
|
|
|
[[nodiscard]] GC::Ref<BigInt const> epoch_nanoseconds() const { return m_epoch_nanoseconds; }
|
|
[[nodiscard]] String const& time_zone() const { return m_time_zone; }
|
|
[[nodiscard]] String const& calendar() const { return m_calendar; }
|
|
|
|
private:
|
|
ZonedDateTime(BigInt const& nanoseconds, String time_zone, String calendar, Object& prototype);
|
|
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
GC::Ref<BigInt const> m_epoch_nanoseconds; // [[EpochNanoseconds]]
|
|
String m_time_zone; // [[TimeZone]]
|
|
String m_calendar; // [[Calendar]]
|
|
};
|
|
|
|
enum class OffsetBehavior {
|
|
Option,
|
|
Exact,
|
|
Wall,
|
|
};
|
|
|
|
enum class MatchBehavior {
|
|
MatchExactly,
|
|
MatchMinutes,
|
|
};
|
|
|
|
ThrowCompletionOr<Crypto::SignedBigInteger> interpret_iso_date_time_offset(VM&, ISODate, Variant<ParsedISODateTime::StartOfDay, Time> const&, OffsetBehavior, double offset_nanoseconds, StringView time_zone, Disambiguation, OffsetOption, MatchBehavior);
|
|
ThrowCompletionOr<GC::Ref<ZonedDateTime>> to_temporal_zoned_date_time(VM&, Value item, Value options = js_undefined());
|
|
ThrowCompletionOr<GC::Ref<ZonedDateTime>> create_temporal_zoned_date_time(VM&, BigInt const& epoch_nanoseconds, String time_zone, String calendar, GC::Ptr<FunctionObject> new_target = {});
|
|
|
|
}
|