1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

LibTimeZone: Operate in UTC-only mode when !ENABLE_TIME_ZONE_DATA

Instead of only having dummy functions that don't work with any input,
let's at least support one time zone: 'UTC'. This matches the basic
Temporal implementation for engines without ECMA-262, for example.
This commit is contained in:
Linus Groh 2022-01-11 20:16:15 +01:00
parent f1276144ba
commit 205d63c3f0
2 changed files with 58 additions and 3 deletions

View file

@ -126,4 +126,24 @@ TEST_CASE(get_time_zone_offset)
EXPECT(!TimeZone::get_time_zone_offset("I don't exist"sv, {}).has_value());
}
#else
TEST_CASE(time_zone_from_string)
{
EXPECT_EQ(TimeZone::time_zone_from_string("UTC"sv), TimeZone::TimeZone::UTC);
EXPECT(!TimeZone::time_zone_from_string("Europe/Paris"sv).has_value());
EXPECT(!TimeZone::time_zone_from_string("Etc/UTC"sv).has_value());
EXPECT(!TimeZone::time_zone_from_string("I don't exist"sv).has_value());
}
TEST_CASE(get_time_zone_offset)
{
EXPECT_EQ(TimeZone::get_time_zone_offset("UTC", AK::Time::from_seconds(123456)), 0);
EXPECT(!TimeZone::get_time_zone_offset("Europe/Paris"sv, {}).has_value());
EXPECT(!TimeZone::get_time_zone_offset("Etc/UTC"sv, {}).has_value());
EXPECT(!TimeZone::get_time_zone_offset("I don't exist"sv, {}).has_value());
}
#endif