mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
LibUnicode: Cache the system time zone
It's expensive to determine the system time zone from disk each time it is requested. This makes LibUnicode cache the result, and provides an API to clear that cache. This will let us set up a monitor to watch for system time zone changes in platform-dependent ways.
This commit is contained in:
parent
e25681203e
commit
b31c11bca5
Notes:
github-actions[bot]
2024-08-25 07:48:47 +00:00
Author: https://github.com/trflynn89
Commit: b31c11bca5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1182
5 changed files with 27 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <LibCore/DateTime.h>
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibTest/TestCase.h>
|
||||
#include <LibUnicode/TimeZone.h>
|
||||
#include <time.h>
|
||||
|
||||
class TimeZoneGuard {
|
||||
|
@ -29,12 +30,14 @@ public:
|
|||
else
|
||||
TRY_OR_FAIL(Core::Environment::unset("TZ"sv));
|
||||
|
||||
Unicode::clear_system_time_zone_cache();
|
||||
tzset();
|
||||
}
|
||||
|
||||
void update(StringView time_zone)
|
||||
{
|
||||
TRY_OR_FAIL(Core::Environment::set("TZ"sv, time_zone, Core::Environment::Overwrite::Yes));
|
||||
Unicode::clear_system_time_zone_cache();
|
||||
tzset();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue