mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibUnicode: Cache all created icu::TimeZone objects
This cache works exactly the same as the existing icu::Locale cache.
This commit is contained in:
parent
6becd13a83
commit
d392c38a73
Notes:
github-actions[bot]
2024-09-03 17:26:56 +00:00
Author: https://github.com/trflynn89
Commit: d392c38a73
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1266
5 changed files with 45 additions and 7 deletions
|
@ -131,14 +131,14 @@ Optional<TimeZoneOffset> time_zone_offset(StringView time_zone, UnixDateTime tim
|
|||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
auto icu_time_zone = adopt_own_if_nonnull(icu::TimeZone::createTimeZone(icu_string(time_zone)));
|
||||
if (!icu_time_zone || *icu_time_zone == icu::TimeZone::getUnknown())
|
||||
auto time_zone_data = TimeZoneData::for_time_zone(time_zone);
|
||||
if (!time_zone_data.has_value())
|
||||
return {};
|
||||
|
||||
i32 raw_offset = 0;
|
||||
i32 dst_offset = 0;
|
||||
|
||||
icu_time_zone->getOffset(static_cast<UDate>(time.milliseconds_since_epoch()), 0, raw_offset, dst_offset, status);
|
||||
time_zone_data->time_zone().getOffset(static_cast<UDate>(time.milliseconds_since_epoch()), 0, raw_offset, dst_offset, status);
|
||||
if (icu_failure(status))
|
||||
return {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue