LibJS: Implement mathematical Temporal.Duration prototypes

Includes:
Temporal.Duration.prototype.negated
Temporal.Duration.prototype.abs
Temporal.Duration.prototype.add
Temporal.Duration.prototype.subtract
This commit is contained in:
Timothy Flynn 2024-11-18 12:48:10 -05:00 committed by Tim Flynn
commit a80523be18
Notes: github-actions[bot] 2024-11-21 00:06:00 +00:00
11 changed files with 591 additions and 0 deletions

View file

@ -18,6 +18,11 @@
namespace JS::Temporal {
enum class ArithmeticOperation {
Add,
Subtract,
};
// https://tc39.es/proposal-temporal/#sec-temporal-units
enum class Unit {
Year,
@ -56,6 +61,7 @@ struct RelativeTo {
};
ThrowCompletionOr<RelativeTo> get_temporal_relative_to_option(VM&, Object const& options);
Unit larger_of_two_temporal_units(Unit, Unit);
bool is_calendar_unit(Unit);
UnitCategory temporal_unit_category(Unit);
ThrowCompletionOr<GC::Ref<Duration>> parse_temporal_duration_string(VM&, StringView iso_string);