mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:07:43 +00:00
LibTimeZone: Perform time-zone-from-string lookups case insensitively
Time zone names in the TZDB are defined to be case insensitive.
This commit is contained in:
parent
b493c2ca90
commit
14535fb67a
2 changed files with 19 additions and 5 deletions
|
@ -235,12 +235,19 @@ namespace TimeZone {
|
|||
HashValueMap<String> hashes;
|
||||
hashes.ensure_capacity(values.size());
|
||||
|
||||
for (auto const& value : values)
|
||||
hashes.set(value.hash(), format_identifier(enum_title, value));
|
||||
for (auto const& alias : aliases)
|
||||
hashes.set(alias.alias.hash(), format_identifier(enum_title, alias.alias));
|
||||
auto hash = [](auto const& value) {
|
||||
return CaseInsensitiveStringViewTraits::hash(value);
|
||||
};
|
||||
|
||||
generate_value_from_string(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes));
|
||||
for (auto const& value : values)
|
||||
hashes.set(hash(value), format_identifier(enum_title, value));
|
||||
for (auto const& alias : aliases)
|
||||
hashes.set(hash(alias.alias), format_identifier(enum_title, alias.alias));
|
||||
|
||||
ValueFromStringOptions options {};
|
||||
options.sensitivity = CaseSensitivity::CaseInsensitive;
|
||||
|
||||
generate_value_from_string(generator, "{}_from_string"sv, enum_title, enum_snake, move(hashes), options);
|
||||
};
|
||||
|
||||
append_from_string("TimeZone"sv, "time_zone"sv, time_zone_data.time_zone_names, time_zone_data.time_zone_aliases);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue