LibCore+LibJS+LibUnicode: Port retrieving time zone offsets to ICU

The changes to tests are due to LibTimeZone incorrectly interpreting
time stamps in the TZDB. The TZDB will list zone transitions in either
UTC or the zone's local time (which is then subject to DST offsets).
LibTimeZone did not handle the latter at all.

For example:

The following rule is in effect until November 18, 6PM UTC.

    America/Chicago -5:50:36 - LMT 1883 Nov 18 18:00u

The following rule is in effect until March 1, 2AM in Chicago time. But
at that time, a DST transition occurs, so the local time is actually
3AM.

    America/Chicago -6:00 Chicago C%sT 1936 Mar 1 2:00
This commit is contained in:
Timothy Flynn 2024-06-25 15:27:20 -04:00 committed by Andreas Kling
commit 672a555f98
Notes: sideshowbarker 2024-07-17 08:45:34 +09:00
15 changed files with 155 additions and 51 deletions

View file

@ -6,15 +6,27 @@
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Time.h>
#include <AK/Vector.h>
#pragma once
namespace Unicode {
struct TimeZoneOffset {
enum class InDST {
No,
Yes,
};
Duration offset;
InDST in_dst { InDST::No };
};
String current_time_zone();
Vector<String> const& available_time_zones();
Vector<String> available_time_zones_in_region(StringView region);
Optional<String> resolve_primary_time_zone(StringView time_zone);
Optional<TimeZoneOffset> time_zone_offset(StringView time_zone, UnixDateTime time);
}