ladybird/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.h
Andreas Kling b6bef6b688 Libraries: Use UTF-16 for JS-visible runtime strings
Produce JS-visible string results as UTF-16 at their source, including
numeric formatting, BigInt and BigFraction formatting, URI encoding,
console formatting, parser errors, regular expression errors, Intl and
Temporal records, LibUnicode locale boundaries, and LibWeb bindings.

Handle fractional radix formatting through the UTF-16 builder view.
2026-06-22 19:51:25 +02:00

45 lines
1.7 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 <AK/String.h>
#include <AK/Utf16String.h>
#include <LibJS/Runtime/Completion.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Temporal/AbstractOperations.h>
#include <LibJS/Runtime/Temporal/ISORecords.h>
#include <LibJS/Runtime/Temporal/PlainDate.h>
namespace JS::Temporal {
class PlainYearMonth final : public Object {
JS_OBJECT(PlainYearMonth, Object);
GC_DECLARE_ALLOCATOR(PlainYearMonth);
public:
virtual ~PlainYearMonth() override = default;
[[nodiscard]] ISODate iso_date() const { return m_iso_date; }
[[nodiscard]] Utf16String const& calendar() const { return m_calendar; }
private:
PlainYearMonth(ISODate, Utf16String calendar, Object& prototype);
ISODate m_iso_date; // [[ISODate]]
Utf16String m_calendar; // [[Calendar]]
};
ThrowCompletionOr<GC::Ref<PlainYearMonth>> to_temporal_year_month(VM&, Value item, Value options = js_undefined());
bool iso_year_month_within_limits(ISODate);
ISOYearMonth balance_iso_year_month(double year, double month);
ThrowCompletionOr<GC::Ref<PlainYearMonth>> create_temporal_year_month(VM&, ISODate, Utf16String calendar, GC::Ptr<FunctionObject> new_target = {});
Utf16String temporal_year_month_to_string(PlainYearMonth const&, ShowCalendar);
ThrowCompletionOr<GC::Ref<Duration>> difference_temporal_plain_year_month(VM&, DurationOperation, PlainYearMonth const&, Value other, Value options);
ThrowCompletionOr<GC::Ref<PlainYearMonth>> add_duration_to_year_month(VM&, ArithmeticOperation, PlainYearMonth const&, Value temporal_duration_like, Value options);
}