mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:47:46 +00:00
LibJS: Simplify Temporal unit AOs
This is an editorial change in the Temporal spec.
See: 1b3d018
This commit is contained in:
parent
b9beb2b120
commit
4c77575ec5
16 changed files with 347 additions and 390 deletions
|
@ -41,6 +41,12 @@ enum class OptionType {
|
|||
Number
|
||||
};
|
||||
|
||||
enum class UnitGroup {
|
||||
Date,
|
||||
Time,
|
||||
DateTime,
|
||||
};
|
||||
|
||||
struct ISODateTime {
|
||||
i32 year;
|
||||
u8 month;
|
||||
|
@ -115,6 +121,8 @@ struct SecondsStringPrecision {
|
|||
u32 increment;
|
||||
};
|
||||
|
||||
struct TemporalUnitRequired { };
|
||||
|
||||
ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(GlobalObject&, Value items, Vector<OptionType> const& element_types);
|
||||
ThrowCompletionOr<Object*> get_options_object(GlobalObject&, Value options);
|
||||
ThrowCompletionOr<Value> get_option(GlobalObject&, Object const& options, PropertyKey const& property, Vector<OptionType> const& types, Vector<StringView> const& values, Value fallback);
|
||||
|
@ -131,11 +139,8 @@ ThrowCompletionOr<String> to_show_offset_option(GlobalObject&, Object const& nor
|
|||
ThrowCompletionOr<u64> to_temporal_rounding_increment(GlobalObject&, Object const& normalized_options, Optional<double> dividend, bool inclusive);
|
||||
ThrowCompletionOr<u64> to_temporal_date_time_rounding_increment(GlobalObject&, Object const& normalized_options, StringView smallest_unit);
|
||||
ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(GlobalObject&, Object const& normalized_options);
|
||||
ThrowCompletionOr<Optional<String>> to_largest_temporal_unit(GlobalObject&, Object const& normalized_options, Vector<StringView> const& disallowed_units, Optional<String> fallback, Optional<String> auto_value = {});
|
||||
ThrowCompletionOr<Optional<String>> to_smallest_temporal_unit(GlobalObject&, Object const& normalized_options, Vector<StringView> const& disallowed_units, Optional<String> fallback);
|
||||
ThrowCompletionOr<String> to_temporal_duration_total_unit(GlobalObject& global_object, Object const& normalized_options);
|
||||
ThrowCompletionOr<Optional<String>> get_temporal_unit(GlobalObject&, Object const& normalized_options, PropertyKey const&, UnitGroup, Variant<TemporalUnitRequired, Optional<StringView>> const& default_, Vector<StringView> const& extra_values = {});
|
||||
ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject&, Object const& options);
|
||||
ThrowCompletionOr<void> validate_temporal_unit_range(GlobalObject&, StringView largest_unit, StringView smallest_unit);
|
||||
StringView larger_of_two_temporal_units(StringView, StringView);
|
||||
ThrowCompletionOr<Object*> merge_largest_unit_option(GlobalObject&, Object const* options, String largest_unit);
|
||||
Optional<u16> maximum_temporal_duration_rounding_increment(StringView unit);
|
||||
|
@ -164,7 +169,7 @@ ThrowCompletionOr<double> to_positive_integer(GlobalObject&, Value argument);
|
|||
ThrowCompletionOr<Object*> prepare_temporal_fields(GlobalObject&, Object const& fields, Vector<String> const& field_names, Vector<StringView> const& required_fields);
|
||||
ThrowCompletionOr<Object*> prepare_partial_temporal_fields(GlobalObject&, Object const& fields, Vector<String> const& field_names);
|
||||
|
||||
// 13.45 ToIntegerThrowOnInfinity ( argument ), https://tc39.es/proposal-temporal/#sec-temporal-tointegerthrowoninfinity
|
||||
// 13.41 ToIntegerThrowOnInfinity ( argument ), https://tc39.es/proposal-temporal/#sec-temporal-tointegerthrowoninfinity
|
||||
template<typename... Args>
|
||||
ThrowCompletionOr<double> to_integer_throw_on_infinity(GlobalObject& global_object, Value argument, ErrorType error_type, Args... args)
|
||||
{
|
||||
|
@ -183,7 +188,7 @@ ThrowCompletionOr<double> to_integer_throw_on_infinity(GlobalObject& global_obje
|
|||
return integer;
|
||||
}
|
||||
|
||||
// 13.46 ToIntegerWithoutRounding ( argument ), https://tc39.es/proposal-temporal/#sec-temporal-tointegerwithoutrounding
|
||||
// 13.42 ToIntegerWithoutRounding ( argument ), https://tc39.es/proposal-temporal/#sec-temporal-tointegerwithoutrounding
|
||||
template<typename... Args>
|
||||
ThrowCompletionOr<double> to_integer_without_rounding(GlobalObject& global_object, Value argument, ErrorType error_type, Args... args)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue