2021-09-02 08:32:43 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								/*
 
							 
						 
					
						
							
								
									
										
										
										
											2025-02-28 08:54:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 *  Copyright  ( c )  2021 - 2025 ,  Tim  Flynn  < trflynn89 @ ladybird . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 08:32:43 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 16:20:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <AK/QuickSort.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibJS/Runtime/Array.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 08:32:43 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibJS/Runtime/GlobalObject.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibJS/Runtime/Intl/Locale.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibUnicode/DateTimeFormat.h> 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								# include  <LibUnicode/Locale.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-25 11:33:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibUnicode/TimeZone.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# include  <LibUnicode/UnicodeKeywords.h> 
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 08:32:43 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace  JS : : Intl  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC_DEFINE_ALLOCATOR ( Locale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-19 09:45:05 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < Locale >  Locale : : create ( Realm &  realm ,  GC : : Ref < Locale >  source_locale ,  String  locale_tag ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 18:23:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-14 05:50:17 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  locale  =  realm . create < Locale > ( realm . intrinsics ( ) . intl_locale_prototype ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-08 13:23:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > set_locale ( move ( locale_tag ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > m_calendar  =  source_locale - > m_calendar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > m_case_first  =  source_locale - > m_case_first ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > m_collation  =  source_locale - > m_collation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > m_hour_cycle  =  source_locale - > m_hour_cycle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > m_numbering_system  =  source_locale - > m_numbering_system ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    locale - > m_numeric  =  source_locale - > m_numeric ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 13:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  locale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-28 08:54:42 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 15 Locale Objects, https://tc39.es/ecma402/#locale-objects
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 13:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								Locale : : Locale ( Object &  prototype ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    :  Object ( ConstructWithPrototypeTag : : Tag ,  prototype ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 18:23:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.1 CreateArrayFromListOrRestricted ( list , restricted )
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  GC : : Ref < Array >  create_array_from_list_or_restricted ( VM &  vm ,  Vector < String >  list ,  Optional < String >  restricted ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 08:25:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto &  realm  =  * vm . current_realm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. If restricted is not undefined, then
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( restricted . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // a. Set list to « restricted ».
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        list  =  {  restricted . release_value ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Return ! CreateArrayFromList( list ).
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-15 20:23:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  Array : : create_from < String > ( realm ,  list ,  [ & vm ] ( auto  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  PrimitiveString : : create ( vm ,  move ( value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// 1.1.2 CalendarsOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-calendars-of-locale
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < Array >  calendars_of_locale ( VM &  vm ,  Locale  const &  locale_object ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let restricted be loc.[[Calendar]].
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 13:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Optional < String >  restricted  =  locale_object . has_calendar ( )  ?  locale_object . calendar ( )  :  Optional < String >  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  const &  locale  =  locale_object . locale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    VERIFY ( Unicode : : parse_unicode_locale_id ( locale ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 4. Let list be a List of 1 or more unique canonical calendar identifiers, which must be lower case String values conforming to the type sequence from UTS 35 Unicode Locale Identifier, section 3.2, sorted in descending preference of those in common use for date and time formatting in locale.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  list  =  Unicode : : available_calendars ( locale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 5. Return ! CreateArrayFromListOrRestricted( list, restricted ).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 08:25:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  create_array_from_list_or_restricted ( vm ,  move ( list ) ,  move ( restricted ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:10:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:28:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.3 CollationsOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-collations-of-locale
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < Array >  collations_of_locale ( VM &  vm ,  Locale  const &  locale_object ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:28:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let restricted be loc.[[Collation]].
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 13:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Optional < String >  restricted  =  locale_object . has_collation ( )  ?  locale_object . collation ( )  :  Optional < String >  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:28:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  const &  locale  =  locale_object . locale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    VERIFY ( Unicode : : parse_unicode_locale_id ( locale ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:28:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 09:07:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 4. Let list be a List of 1 or more unique canonical collation identifiers, which must be lower case String values conforming to the type sequence from UTS 35 Unicode Locale Identifier, section 3.2, ordered as if an Array of the same values had been sorted, using %Array.prototype.sort% using undefined as comparefn, of those in common use for string comparison in locale. The values "standard" and "search" must be excluded from list.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  list  =  Unicode : : available_collations ( locale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:28:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 5. Return ! CreateArrayFromListOrRestricted( list, restricted ).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 08:25:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  create_array_from_list_or_restricted ( vm ,  move ( list ) ,  move ( restricted ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 12:28:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:41:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.4 HourCyclesOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-hour-cycles-of-locale
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < Array >  hour_cycles_of_locale ( VM &  vm ,  Locale  const &  locale_object ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:41:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let restricted be loc.[[HourCycle]].
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 13:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Optional < String >  restricted  =  locale_object . has_hour_cycle ( )  ?  locale_object . hour_cycle ( )  :  Optional < String >  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:41:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  const &  locale  =  locale_object . locale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    VERIFY ( Unicode : : parse_unicode_locale_id ( locale ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:41:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 4. Let list be a List of 1 or more unique hour cycle identifiers, which must be lower case String values indicating either the 12-hour format ("h11", "h12") or the 24-hour format ("h23", "h24"), sorted in descending preference of those in common use for date and time formatting in locale.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  list  =  Unicode : : available_hour_cycles ( locale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:41:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 5. Return ! CreateArrayFromListOrRestricted( list, restricted ).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 08:25:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  create_array_from_list_or_restricted ( vm ,  move ( list ) ,  move ( restricted ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 13:41:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 14:19:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.5 NumberingSystemsOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-numbering-systems-of-locale
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < Array >  numbering_systems_of_locale ( VM &  vm ,  Locale  const &  locale_object ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 14:19:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let restricted be loc.[[NumberingSystem]].
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-19 13:13:57 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Optional < String >  restricted  =  locale_object . has_numbering_system ( )  ?  locale_object . numbering_system ( )  :  Optional < String >  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 14:19:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  const &  locale  =  locale_object . locale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    VERIFY ( Unicode : : parse_unicode_locale_id ( locale ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 14:19:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 4. Let list be a List of 1 or more unique canonical numbering system identifiers, which must be lower case String values conforming to the type sequence from UTS 35 Unicode Locale Identifier, section 3.2, sorted in descending preference of those in common use for formatting numeric values in locale.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  list  =  Unicode : : available_number_systems ( locale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 14:19:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 5. Return ! CreateArrayFromListOrRestricted( list, restricted ).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 08:25:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  create_array_from_list_or_restricted ( vm ,  move ( list ) ,  move ( restricted ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 14:19:23 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 16:20:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.6 TimeZonesOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-time-zones-of-locale
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// NOTE: Our implementation takes a region rather than a Locale object to avoid needlessly parsing the locale twice.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 04:01:23 +13:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								GC : : Ref < Array >  time_zones_of_locale ( VM &  vm ,  StringView  region ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 16:20:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-20 08:25:24 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto &  realm  =  * vm . current_realm ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 16:20:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. Let region be the substring of locale corresponding to the unicode_region_subtag production of the unicode_language_id.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 4. Let list be a List of unique canonical time zone identifiers, which must be String values indicating a canonical Zone name of the IANA Time Zone Database, ordered as if an Array of the same values had been sorted using %Array.prototype.sort% using undefined as comparefn, of those in common use in region. If no time zones are commonly used in region, let list be a new empty List.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-25 11:33:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  list  =  Unicode : : available_time_zones_in_region ( region ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 16:20:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 5. Return ! CreateArrayFromList( list ).
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-25 11:33:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  Array : : create_from < String > ( realm ,  list ,  [ & vm ] ( auto  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  PrimitiveString : : create ( vm ,  value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 16:20:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 19:50:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.7 CharacterDirectionOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-character-direction-of-locale
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 15:39:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								StringView  character_direction_of_locale ( Locale  const &  locale_object ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 19:50:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  const &  locale  =  locale_object . locale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    VERIFY ( Unicode : : parse_unicode_locale_id ( locale ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 19:50:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 3. If the default general ordering of characters (characterOrder) within a line in locale is right-to-left, return "rtl".
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( Unicode : : is_locale_character_ordering_right_to_left ( locale ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-08 13:36:10 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  " rtl " sv ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-05 19:50:24 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 4. Return "ltr".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  " ltr " sv ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								struct  FirstDayStringAndValue  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    StringView  weekday ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    StringView  string ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    u8  value  {  0  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// Table 1: First Day String and Value, https://tc39.es/proposal-intl-locale-info/#table-locale-first-day-option-value
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								static  constexpr  auto  first_day_string_and_value_table  =  to_array < FirstDayStringAndValue > ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 0 " sv ,  " sun " sv ,  7  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 1 " sv ,  " mon " sv ,  1  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 2 " sv ,  " tue " sv ,  2  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 3 " sv ,  " wed " sv ,  3  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 4 " sv ,  " thu " sv ,  4  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 5 " sv ,  " fri " sv ,  5  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 6 " sv ,  " sat " sv ,  6  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    {  " 7 " sv ,  " sun " sv ,  7  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// 1.1.8 WeekdayToString ( fw ), https://tc39.es/proposal-intl-locale-info/#sec-weekday-to-string
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								StringView  weekday_to_string ( StringView  weekday ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 1. For each row of Table 1, except the header row, in table order, do
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( auto  const &  row  :  first_day_string_and_value_table )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // a. Let w be the name given in the Weekday column of the row.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // b. Let s be the name given in the String column of the row.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // c. If fw is equal to w, return s.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( weekday  = =  row . weekday ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  row . string ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 2. Return fw.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  weekday ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.9 StringToWeekdayValue ( fw ), https://tc39.es/proposal-intl-locale-info/#sec-string-to-weekday-value
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								Optional < u8 >  string_to_weekday_value ( StringView  weekday ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. For each row of Table 1, except the header row, in table order, do
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ( auto  const &  row  :  first_day_string_and_value_table )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // a. Let s be the name given in the String column of the row.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // b. Let v be the name given in the Value column of the row.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // c. If fw is equal to s, return v.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( weekday  = =  row . string ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  row . value ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 2. Return undefined.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  u8  weekday_to_integer ( Optional < Unicode : : Weekday >  const &  weekday ,  Unicode : : Weekday  falllback ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // NOTE: This fallback will be used if the ICU data lookup failed. Its value should be that of the
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //       default region ("001") in the CLDR.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    switch  ( weekday . value_or ( falllback ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Monday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Tuesday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Wednesday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  3 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Thursday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  4 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Friday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  5 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Saturday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  6 ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    case  Unicode : : Weekday : : Sunday : 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return  7 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								static  Vector < u8 >  weekend_of_locale ( ReadonlySpan < Unicode : : Weekday >  const &  weekend_days ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Vector < u8 >  weekend ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    weekend . ensure_capacity ( weekend_days . size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ( auto  day  :  weekend_days ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        weekend . unchecked_append ( weekday_to_integer ( day ,  day ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    quick_sort ( weekend ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  weekend ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								// 1.1.10 WeekInfoOfLocale ( loc ), https://tc39.es/proposal-intl-locale-info/#sec-week-info-of-locale
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-30 11:50:02 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								WeekInfo  week_info_of_locale ( Locale  const &  locale_object ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 1. Let locale be loc.[[Locale]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    auto  const &  locale  =  locale_object . locale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 2. Assert: locale matches the unicode_locale_id production.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    VERIFY ( Unicode : : parse_unicode_locale_id ( locale ) . has_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 3. Let r be a record whose fields are defined by Table 2, with values based on locale.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    auto  locale_week_info  =  Unicode : : week_info_of_locale ( locale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    WeekInfo  week_info  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    week_info . minimal_days  =  locale_week_info . minimal_days_in_first_week ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-23 09:14:27 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    week_info . first_day  =  weekday_to_integer ( locale_week_info . first_day_of_week ,  Unicode : : Weekday : : Monday ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2024-06-12 17:00:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    week_info . weekend  =  weekend_of_locale ( locale_week_info . weekend_days ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    Optional < u8 >  first_day_of_week ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( locale_object . has_first_day_of_week ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // 4. Let fws be loc.[[FirstDayOfWeek]].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        auto  const &  first_day_of_week_string  =  locale_object . first_day_of_week ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // 5. Let fw be !StringToWeekdayValue(fws).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        first_day_of_week  =  string_to_weekday_value ( first_day_of_week_string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // 6. If fw is not undefined, then
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( first_day_of_week . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // a. Set r.[[FirstDay]] to fw.
 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        week_info . first_day  =  * first_day_of_week ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-03 10:18:18 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-11 09:29:06 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // 7. Return r.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-06 08:30:53 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  week_info ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-02 08:32:43 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								}