summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2021-11-23 23:14:19 +0000
committerLinus Groh <mail@linusgroh.de>2021-11-24 17:53:00 +0000
commit7dc846d51c1f3f96e78904c0cab6aad6212e911d (patch)
tree370b84d65d292e8105e2506c5519a26a6203d602 /Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
parent9559cea8e5e770340ded90441a6586012b77824e (diff)
downloadserenity-7dc846d51c1f3f96e78904c0cab6aad6212e911d.zip
LibJS: Implement balance_duration_relative()
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal/Duration.h')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Duration.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
index 7fb57bbefd..b4341cbd97 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.h
@@ -117,6 +117,14 @@ struct UnbalancedDuration {
double days;
};
+// Used by BalanceDurationRelative to temporarily hold values
+struct RelativeBalancedDuration {
+ double years;
+ double months;
+ double weeks;
+ double days;
+};
+
// Table 7: Properties of a TemporalDurationLike, https://tc39.es/proposal-temporal/#table-temporal-temporaldurationlike-properties
template<typename StructT, typename ValueT>
@@ -154,6 +162,7 @@ ThrowCompletionOr<double> calculate_offset_shift(GlobalObject&, Value relative_t
BigInt* total_duration_nanoseconds(GlobalObject&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, BigInt const& nanoseconds, double offset_shift);
ThrowCompletionOr<BalancedDuration> balance_duration(GlobalObject&, double days, double hours, double minutes, double seconds, double milliseconds, double microseconds, BigInt const& nanoseconds, String const& largest_unit, Object* relative_to = nullptr);
ThrowCompletionOr<UnbalancedDuration> unbalance_duration_relative(GlobalObject&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to);
+ThrowCompletionOr<RelativeBalancedDuration> balance_duration_relative(GlobalObject&, double years, double months, double weeks, double days, String const& largest_unit, Value relative_to);
ThrowCompletionOr<TemporalDuration> add_duration(GlobalObject&, double years1, double months1, double weeks1, double days1, double hours1, double minutes1, double seconds1, double milliseconds1, double microseconds1, double nanoseconds1, double years2, double months2, double weeks2, double days2, double hours2, double minutes2, double seconds2, double milliseconds2, double microseconds2, double nanoseconds2, Value relative_to_value);
ThrowCompletionOr<MoveRelativeDateResult> move_relative_date(GlobalObject&, Object& calendar, PlainDate& relative_to, Duration& duration);
ThrowCompletionOr<ZonedDateTime*> move_relative_zoned_date_time(GlobalObject&, ZonedDateTime&, double years, double months, double weeks, double days);