ladybird/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.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

57 lines
1.3 KiB
C++

/*
* Copyright (c) 2021-2024, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/NativeFunction.h>
namespace JS::Intl {
class DateTimeFormatConstructor final : public NativeFunction {
JS_OBJECT(DateTimeFormatConstructor, NativeFunction);
GC_DECLARE_ALLOCATOR(DateTimeFormatConstructor);
public:
virtual void initialize(Realm&) override;
virtual ~DateTimeFormatConstructor() override = default;
virtual ThrowCompletionOr<Value> call() override;
virtual ThrowCompletionOr<GC::Ref<Object>> construct(FunctionObject& new_target) override;
private:
explicit DateTimeFormatConstructor(Realm&);
virtual bool has_constructor() const override { return true; }
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
};
enum class OptionRequired {
Any,
Date,
Time,
YearMonth,
MonthDay,
};
enum class OptionDefaults {
All,
Date,
Time,
YearMonth,
MonthDay,
ZonedDateTime,
};
enum class OptionInherit {
All,
Relevant,
};
ThrowCompletionOr<GC::Ref<DateTimeFormat>> create_date_time_format(VM&, FunctionObject& new_target, Value locales_value, Value options_value, OptionRequired, OptionDefaults, Optional<Utf16View> const& to_locale_string_time_zone = {});
Utf16String format_offset_time_zone_identifier(double offset_minutes);
}