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