| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  |  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | #include <LibJS/Runtime/Completion.h>
 | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  | #include <LibJS/Runtime/Object.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-04 22:28:21 +01:00
										 |  |  | #include <LibJS/Runtime/Temporal/PlainDate.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-16 18:04:58 +01:00
										 |  |  | #include <LibJS/Runtime/Temporal/PlainMonthDay.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-16 00:35:05 +01:00
										 |  |  | #include <LibJS/Runtime/Temporal/PlainYearMonth.h>
 | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  | #include <LibJS/Runtime/Value.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Temporal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  | class Calendar final : public Object { | 
					
						
							|  |  |  |     JS_OBJECT(Calendar, Object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-07-21 23:45:44 +01:00
										 |  |  |     Calendar(String identifier, Object& prototype); | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  |     virtual ~Calendar() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-07 21:50:35 +01:00
										 |  |  |     [[nodiscard]] String const& identifier() const { return m_identifier; } | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     // 12.5 Properties of Temporal.Calendar Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-calendar-instances
 | 
					
						
							| 
									
										
										
										
											2021-08-01 16:44:49 +01:00
										 |  |  |     String m_identifier; // [[Identifier]]
 | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | ThrowCompletionOr<Calendar*> create_temporal_calendar(GlobalObject&, String const& identifier, FunctionObject const* new_target = nullptr); | 
					
						
							| 
									
										
										
										
											2021-07-14 21:01:12 +01:00
										 |  |  | bool is_builtin_calendar(String const& identifier); | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | ThrowCompletionOr<Calendar*> get_builtin_calendar(GlobalObject&, String const& identifier); | 
					
						
							| 
									
										
										
										
											2021-07-19 00:29:26 +03:00
										 |  |  | Calendar* get_iso8601_calendar(GlobalObject&); | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | ThrowCompletionOr<Vector<String>> calendar_fields(GlobalObject&, Object& calendar, Vector<StringView> const& field_names); | 
					
						
							|  |  |  | ThrowCompletionOr<double> calendar_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<double> calendar_month(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<String> calendar_month_code(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<double> calendar_day(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_day_of_week(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_day_of_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_week_of_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_days_in_week(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_days_in_month(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_days_in_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_months_in_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_in_leap_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_era(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Value> calendar_era_year(GlobalObject&, Object& calendar, Object& date_like); | 
					
						
							|  |  |  | ThrowCompletionOr<Object*> to_temporal_calendar(GlobalObject&, Value); | 
					
						
							|  |  |  | ThrowCompletionOr<Object*> to_temporal_calendar_with_iso_default(GlobalObject&, Value); | 
					
						
							|  |  |  | ThrowCompletionOr<Object*> get_temporal_calendar_with_iso_default(GlobalObject&, Object&); | 
					
						
							|  |  |  | ThrowCompletionOr<PlainDate*> date_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const& options); | 
					
						
							|  |  |  | ThrowCompletionOr<PlainYearMonth*> year_month_from_fields(GlobalObject&, Object& calendar, Object const& fields, Object const* options = nullptr); | 
					
						
							|  |  |  | ThrowCompletionOr<PlainMonthDay*> month_day_from_fields(GlobalObject& global_object, Object& calendar, Object const& fields, Object const* options = nullptr); | 
					
						
							| 
									
										
										
										
											2021-08-18 21:15:04 +01:00
										 |  |  | String format_calendar_annotation(StringView id, StringView show_calendar); | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | ThrowCompletionOr<bool> calendar_equals(GlobalObject&, Object& one, Object& two); | 
					
						
							|  |  |  | ThrowCompletionOr<Object*> consolidate_calendars(GlobalObject&, Object& one, Object& two); | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  | bool is_iso_leap_year(i32 year); | 
					
						
							| 
									
										
										
										
											2021-07-23 18:19:45 +03:00
										 |  |  | u16 iso_days_in_year(i32 year); | 
					
						
							| 
									
										
										
										
											2021-07-26 16:48:47 +03:00
										 |  |  | u8 iso_days_in_month(i32 year, u8 month); | 
					
						
							| 
									
										
										
										
											2021-07-23 17:46:20 +03:00
										 |  |  | u8 to_iso_day_of_week(i32 year, u8 month, u8 day); | 
					
						
							| 
									
										
										
										
											2021-07-23 17:58:44 +03:00
										 |  |  | u16 to_iso_day_of_year(i32 year, u8 month, u8 day); | 
					
						
							| 
									
										
										
										
											2021-07-23 18:19:45 +03:00
										 |  |  | u8 to_iso_week_of_year(i32 year, u8 month, u8 day); | 
					
						
							| 
									
										
										
										
											2021-07-26 16:48:47 +03:00
										 |  |  | String build_iso_month_code(u8 month); | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | ThrowCompletionOr<double> resolve_iso_month(GlobalObject&, Object const& fields); | 
					
						
							|  |  |  | ThrowCompletionOr<ISODate> iso_date_from_fields(GlobalObject&, Object const& fields, Object const& options); | 
					
						
							|  |  |  | ThrowCompletionOr<ISOYearMonth> iso_year_month_from_fields(GlobalObject&, Object const& fields, Object const& options); | 
					
						
							|  |  |  | ThrowCompletionOr<ISOMonthDay> iso_month_day_from_fields(GlobalObject&, Object const& fields, Object const& options); | 
					
						
							| 
									
										
										
										
											2021-07-23 16:35:36 +03:00
										 |  |  | i32 iso_year(Object& temporal_object); | 
					
						
							| 
									
										
										
										
											2021-07-23 16:46:46 +03:00
										 |  |  | u8 iso_month(Object& temporal_object); | 
					
						
							| 
									
										
										
										
											2021-07-23 16:56:38 +03:00
										 |  |  | String iso_month_code(Object& temporal_object); | 
					
						
							| 
									
										
										
										
											2021-07-23 17:05:10 +03:00
										 |  |  | u8 iso_day(Object& temporal_object); | 
					
						
							| 
									
										
										
										
											2021-09-16 21:42:01 +01:00
										 |  |  | ThrowCompletionOr<Object*> default_merge_fields(GlobalObject&, Object const& fields, Object const& additional_fields); | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |