| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Optional.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/Object.h>
 | 
					
						
							| 
									
										
										
										
											2021-07-27 00:21:16 +01:00
										 |  |  | #include <LibJS/Runtime/Temporal/AbstractOperations.h>
 | 
					
						
							| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Temporal { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TimeZone final : public Object { | 
					
						
							|  |  |  |     JS_OBJECT(TimeZone, Object); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-15 23:20:43 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  |     // Needs to store values in the range -8.64 * 10^13 to 8.64 * 10^13
 | 
					
						
							| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  |     using OffsetType = double; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-21 23:45:44 +01:00
										 |  |  |     TimeZone(String identifier, Object& prototype); | 
					
						
							| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  |     virtual ~TimeZone() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-07 21:50:35 +01:00
										 |  |  |     [[nodiscard]] String const& identifier() const { return m_identifier; } | 
					
						
							|  |  |  |     [[nodiscard]] Optional<OffsetType> const& offset_nanoseconds() const { return m_offset_nanoseconds; } | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  |     void set_offset_nanoseconds(OffsetType offset_nanoseconds) { m_offset_nanoseconds = offset_nanoseconds; }; | 
					
						
							| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     // 11.5 Properties of Temporal.TimeZone Instances, https://tc39.es/proposal-temporal/#sec-properties-of-temporal-timezone-instances
 | 
					
						
							| 
									
										
										
										
											2021-08-01 16:44:49 +01:00
										 |  |  |     String m_identifier;                       // [[Identifier]]
 | 
					
						
							|  |  |  |     Optional<OffsetType> m_offset_nanoseconds; // [[OffsetNanoseconds]]
 | 
					
						
							| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool is_valid_time_zone_name(String const& time_zone); | 
					
						
							|  |  |  | String canonicalize_time_zone_name(String const& time_zone); | 
					
						
							|  |  |  | String default_time_zone(); | 
					
						
							| 
									
										
										
										
											2021-09-16 01:49:19 +03:00
										 |  |  | ThrowCompletionOr<String> parse_temporal_time_zone(GlobalObject&, String const&); | 
					
						
							|  |  |  | ThrowCompletionOr<TimeZone*> create_temporal_time_zone(GlobalObject&, String const& identifier, FunctionObject const* new_target = nullptr); | 
					
						
							| 
									
										
										
										
											2021-09-16 01:19:37 +03:00
										 |  |  | ISODateTime get_iso_parts_from_epoch(BigInt const& epoch_nanoseconds); | 
					
						
							| 
									
										
										
										
											2021-07-25 20:19:37 +01:00
										 |  |  | i64 get_iana_time_zone_offset_nanoseconds(BigInt const& epoch_nanoseconds, String const& time_zone_identifier); | 
					
						
							| 
									
										
										
										
											2021-09-16 01:49:19 +03:00
										 |  |  | ThrowCompletionOr<double> parse_time_zone_offset_string(GlobalObject&, String const&); | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  | String format_time_zone_offset_string(double offset_nanoseconds); | 
					
						
							| 
									
										
										
										
											2021-09-16 01:49:19 +03:00
										 |  |  | ThrowCompletionOr<Object*> to_temporal_time_zone(GlobalObject&, Value temporal_time_zone_like); | 
					
						
							|  |  |  | ThrowCompletionOr<double> get_offset_nanoseconds_for(GlobalObject&, Value time_zone, Instant&); | 
					
						
							|  |  |  | ThrowCompletionOr<String> builtin_time_zone_get_offset_string_for(GlobalObject&, Value time_zone, Instant&); | 
					
						
							|  |  |  | ThrowCompletionOr<PlainDateTime*> builtin_time_zone_get_plain_date_time_for(GlobalObject&, Value time_zone, Instant&, Object& calendar); | 
					
						
							| 
									
										
										
										
											2021-07-11 21:04:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool is_valid_time_zone_numeric_utc_offset_syntax(String const&); | 
					
						
							| 
									
										
										
										
											2021-07-06 23:53:27 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |