mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibJS+LibUnicode: Port retrieving available regional time zones to ICU
This commit is contained in:
parent
4fc0fba646
commit
1b2d47e6bb
Notes:
sideshowbarker
2024-07-17 09:56:35 +09:00
Author: https://github.com/trflynn89
Commit: 1b2d47e6bb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/281
4 changed files with 41 additions and 20 deletions
|
@ -8,9 +8,9 @@
|
|||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Intl/Locale.h>
|
||||
#include <LibTimeZone/TimeZone.h>
|
||||
#include <LibUnicode/DateTimeFormat.h>
|
||||
#include <LibUnicode/Locale.h>
|
||||
#include <LibUnicode/TimeZone.h>
|
||||
#include <LibUnicode/UnicodeKeywords.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
@ -142,12 +142,11 @@ NonnullGCPtr<Array> time_zones_of_locale(VM& vm, StringView region)
|
|||
// 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.
|
||||
auto list = TimeZone::time_zones_in_region(region);
|
||||
quick_sort(list);
|
||||
auto list = Unicode::available_time_zones_in_region(region);
|
||||
|
||||
// 5. Return ! CreateArrayFromList( list ).
|
||||
return Array::create_from<StringView>(realm, list, [&vm](auto value) {
|
||||
return PrimitiveString::create(vm, String::from_utf8(value).release_value());
|
||||
return Array::create_from<String>(realm, list, [&vm](auto value) {
|
||||
return PrimitiveString::create(vm, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue