| 
									
										
										
										
											2021-07-27 00:21:16 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-07 22:40:32 +01:00
										 |  |  | #include <LibJS/Runtime/Object.h>
 | 
					
						
							| 
									
										
										
										
											2021-07-27 00:21:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Temporal { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-07 22:40:32 +01:00
										 |  |  | class PlainYearMonth final : public Object { | 
					
						
							|  |  |  |     JS_OBJECT(PlainYearMonth, Object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     PlainYearMonth(i32 iso_year, u8 iso_month, u8 iso_day, Object& calendar, Object& prototype); | 
					
						
							|  |  |  |     virtual ~PlainYearMonth() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     [[nodiscard]] i32 iso_year() const { return m_iso_year; } | 
					
						
							|  |  |  |     [[nodiscard]] u8 iso_month() const { return m_iso_month; } | 
					
						
							|  |  |  |     [[nodiscard]] u8 iso_day() const { return m_iso_day; } | 
					
						
							|  |  |  |     [[nodiscard]] Object const& calendar() const { return m_calendar; } | 
					
						
							|  |  |  |     [[nodiscard]] Object& calendar() { return m_calendar; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     virtual void visit_edges(Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // 9.4 Properties of Temporal.PlainYearMonth Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-plainyearmonth-instances
 | 
					
						
							|  |  |  |     i32 m_iso_year { 0 }; // [[ISOYear]]
 | 
					
						
							|  |  |  |     u8 m_iso_month { 0 }; // [[ISOMonth]]
 | 
					
						
							|  |  |  |     u8 m_iso_day { 0 };   // [[ISODay]]
 | 
					
						
							|  |  |  |     Object& m_calendar;   // [[Calendar]]
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-27 00:21:16 +01:00
										 |  |  | struct ISOYearMonth { | 
					
						
							|  |  |  |     i32 year; | 
					
						
							|  |  |  |     u8 month; | 
					
						
							| 
									
										
										
										
											2021-08-16 00:35:05 +01:00
										 |  |  |     u8 reference_iso_day; | 
					
						
							| 
									
										
										
										
											2021-07-27 00:21:16 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-16 01:57:24 +03:00
										 |  |  | ThrowCompletionOr<PlainYearMonth*> to_temporal_year_month(GlobalObject& global_object, Value item, Object* options = nullptr); | 
					
						
							|  |  |  | ThrowCompletionOr<ISOYearMonth> regulate_iso_year_month(GlobalObject&, double year, double month, StringView overflow); | 
					
						
							| 
									
										
										
										
											2021-08-16 00:35:05 +01:00
										 |  |  | bool is_valid_iso_month(u8 month); | 
					
						
							| 
									
										
										
										
											2021-08-07 22:40:32 +01:00
										 |  |  | bool iso_year_month_within_limits(i32 year, u8 month); | 
					
						
							| 
									
										
										
										
											2021-08-16 00:35:05 +01:00
										 |  |  | ISOYearMonth balance_iso_year_month(double year, double month); | 
					
						
							|  |  |  | ISOYearMonth constrain_iso_year_month(double year, double month); | 
					
						
							| 
									
										
										
										
											2021-09-16 01:57:24 +03:00
										 |  |  | ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(GlobalObject&, i32 iso_year, u8 iso_month, Object& calendar, u8 reference_iso_day, FunctionObject const* new_target = nullptr); | 
					
						
							|  |  |  | ThrowCompletionOr<String> temporal_year_month_to_string(GlobalObject&, PlainYearMonth&, StringView show_calendar); | 
					
						
							| 
									
										
										
										
											2021-07-27 00:21:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |