2021-11-18 12:30:31 -03:00
|
|
|
/*
|
2024-11-27 18:09:41 -03:00
|
|
|
* Copyright (c) 2021-2024, Tim Flynn <trflynn89@ladybird.org>
|
2021-11-18 12:30:31 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/NativeFunction.h>
|
|
|
|
|
|
|
|
|
|
namespace JS::Intl {
|
|
|
|
|
|
2025-07-19 14:41:08 -03:00
|
|
|
class DateTimeFormatConstructor final : public NativeFunction {
|
2021-11-18 12:30:31 -03:00
|
|
|
JS_OBJECT(DateTimeFormatConstructor, NativeFunction);
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DECLARE_ALLOCATOR(DateTimeFormatConstructor);
|
2021-11-18 12:30:31 -03:00
|
|
|
|
|
|
|
|
public:
|
2023-08-07 03:41:28 -03:00
|
|
|
virtual void initialize(Realm&) override;
|
2021-11-18 12:30:31 -03:00
|
|
|
virtual ~DateTimeFormatConstructor() override = default;
|
|
|
|
|
|
|
|
|
|
virtual ThrowCompletionOr<Value> call() override;
|
2024-11-14 12:01:23 -03:00
|
|
|
virtual ThrowCompletionOr<GC::Ref<Object>> construct(FunctionObject& new_target) override;
|
2021-11-18 12:30:31 -03:00
|
|
|
|
|
|
|
|
private:
|
2022-08-28 18:51:28 -03:00
|
|
|
explicit DateTimeFormatConstructor(Realm&);
|
|
|
|
|
|
2021-11-18 12:30:31 -03:00
|
|
|
virtual bool has_constructor() const override { return true; }
|
2021-11-28 23:16:27 -03:00
|
|
|
|
|
|
|
|
JS_DECLARE_NATIVE_FUNCTION(supported_locales_of);
|
2021-11-18 12:30:31 -03:00
|
|
|
};
|
|
|
|
|
|
2023-07-21 23:13:44 -03:00
|
|
|
enum class OptionRequired {
|
|
|
|
|
Any,
|
|
|
|
|
Date,
|
|
|
|
|
Time,
|
2024-11-27 18:09:41 -03:00
|
|
|
YearMonth,
|
|
|
|
|
MonthDay,
|
2023-07-21 23:13:44 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class OptionDefaults {
|
|
|
|
|
All,
|
|
|
|
|
Date,
|
|
|
|
|
Time,
|
2024-11-27 18:09:41 -03:00
|
|
|
YearMonth,
|
|
|
|
|
MonthDay,
|
|
|
|
|
ZonedDateTime,
|
2023-07-21 23:13:44 -03:00
|
|
|
};
|
|
|
|
|
|
2024-11-27 18:09:41 -03:00
|
|
|
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<String> const& to_locale_string_time_zone = {});
|
2023-10-04 16:45:59 -03:00
|
|
|
String format_offset_time_zone_identifier(double offset_minutes);
|
2022-03-15 11:30:33 -03:00
|
|
|
|
2021-11-18 12:30:31 -03:00
|
|
|
}
|