summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Temporal
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-08-04 22:28:21 +0100
committerAndreas Kling <kling@serenityos.org>2021-08-05 19:19:40 +0200
commite036f4a78616a1eb72d2d372eda78724fb917fa3 (patch)
treec80998bff4a13ad52cbe1b721b7f76722ae962ef /Userland/Libraries/LibJS/Runtime/Temporal
parentdd58d0f6508606993d67df1e256ebd563212be71 (diff)
downloadserenity-e036f4a78616a1eb72d2d372eda78724fb917fa3.zip
LibJS: Make regulate_iso_date() and iso_date_from_fields() use ISODate
No need for TemporalDate, we don't use the calendar field here anyway.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h4
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h3
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp1
5 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp
index 934a38415c..100cc75c47 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp
@@ -659,7 +659,7 @@ double resolve_iso_month(GlobalObject& global_object, Object& fields)
}
// 12.1.38 ISODateFromFields ( fields, options ), https://tc39.es/proposal-temporal/#sec-temporal-isodatefromfields
-Optional<TemporalDate> iso_date_from_fields(GlobalObject& global_object, Object& fields, Object& options)
+Optional<ISODate> iso_date_from_fields(GlobalObject& global_object, Object& fields, Object& options)
{
auto& vm = global_object.vm();
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h
index 94fea7120a..fe2c9bd13c 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h
@@ -8,7 +8,7 @@
#pragma once
#include <LibJS/Runtime/Object.h>
-#include <LibJS/Runtime/Temporal/AbstractOperations.h>
+#include <LibJS/Runtime/Temporal/PlainDate.h>
#include <LibJS/Runtime/Value.h>
namespace JS::Temporal {
@@ -58,7 +58,7 @@ u16 to_iso_day_of_year(i32 year, u8 month, u8 day);
u8 to_iso_week_of_year(i32 year, u8 month, u8 day);
String build_iso_month_code(u8 month);
double resolve_iso_month(GlobalObject&, Object& fields);
-Optional<TemporalDate> iso_date_from_fields(GlobalObject&, Object& fields, Object& options);
+Optional<ISODate> iso_date_from_fields(GlobalObject&, Object& fields, Object& options);
i32 iso_year(Object& temporal_object);
u8 iso_month(Object& temporal_object);
String iso_month_code(Object& temporal_object);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp
index d5113409ff..3ddfde0fa4 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp
@@ -161,7 +161,7 @@ PlainDate* to_temporal_date(GlobalObject& global_object, Value item, Object* opt
}
// 3.5.4 RegulateISODate ( year, month, day, overflow ), https://tc39.es/proposal-temporal/#sec-temporal-regulateisodate
-Optional<TemporalDate> regulate_iso_date(GlobalObject& global_object, double year, double month, double day, String const& overflow)
+Optional<ISODate> regulate_iso_date(GlobalObject& global_object, double year, double month, double day, String const& overflow)
{
auto& vm = global_object.vm();
// 1. Assert: year, month, and day are integers.
@@ -187,7 +187,7 @@ Optional<TemporalDate> regulate_iso_date(GlobalObject& global_object, double yea
return {};
}
// b. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
- return TemporalDate { .year = y, .month = m, .day = d, .calendar = {} };
+ return ISODate { .year = y, .month = m, .day = d };
}
// 4. If overflow is "constrain", then
else if (overflow == "constrain"sv) {
@@ -206,7 +206,7 @@ Optional<TemporalDate> regulate_iso_date(GlobalObject& global_object, double yea
day = constrain_to_range(day, 1, iso_days_in_month(y, month));
// c. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }.
- return TemporalDate { .year = y, .month = static_cast<u8>(month), .day = static_cast<u8>(day), .calendar = {} };
+ return ISODate { .year = y, .month = static_cast<u8>(month), .day = static_cast<u8>(day) };
}
VERIFY_NOT_REACHED();
}
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
index 6cab0c015d..b0985fe52d 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.h
@@ -7,7 +7,6 @@
#pragma once
-#include <LibJS/Runtime/Temporal/AbstractOperations.h>
#include <LibJS/Runtime/Value.h>
namespace JS::Temporal {
@@ -43,7 +42,7 @@ struct ISODate {
PlainDate* create_temporal_date(GlobalObject&, i32 iso_year, u8 iso_month, u8 iso_day, Object& calendar, FunctionObject* new_target = nullptr);
PlainDate* to_temporal_date(GlobalObject&, Value item, Object* options = nullptr);
-Optional<TemporalDate> regulate_iso_date(GlobalObject&, double year, double month, double day, String const& overflow);
+Optional<ISODate> regulate_iso_date(GlobalObject&, double year, double month, double day, String const& overflow);
bool is_valid_iso_date(i32 year, u8 month, u8 day);
ISODate balance_iso_date(i32 year, i32 month, i32 day);
i8 compare_iso_date(i32 year1, u8 month1, u8 day1, i32 year2, u8 month2, u8 day2);
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
index 745f47e442..974bd04472 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp
@@ -7,6 +7,7 @@
#include <AK/Checked.h>
#include <AK/TypeCasts.h>
#include <LibJS/Runtime/GlobalObject.h>
+#include <LibJS/Runtime/Temporal/AbstractOperations.h>
#include <LibJS/Runtime/Temporal/Calendar.h>
#include <LibJS/Runtime/Temporal/PlainDate.h>
#include <LibJS/Runtime/Temporal/PlainDateConstructor.h>