mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:07:34 +00:00
LibTimeZone: Begin generating GMT offset rules for each time zone
This is a rather naive implementation, but serves as a first pass at determining the GMT offset for a time zone at a particular point in time. This implementation ignores DST (because we are not parsing any RULE entries yet), and ignores any offset patterns of the form "Mon>4" or "lastSun".
This commit is contained in:
parent
e9c42d0bc5
commit
09c0324880
4 changed files with 199 additions and 34 deletions
|
@ -24,4 +24,13 @@ Optional<StringView> canonicalize_time_zone(StringView time_zone)
|
|||
return canonical_time_zone;
|
||||
}
|
||||
|
||||
Optional<i64> __attribute__((weak)) get_time_zone_offset(TimeZone, AK::Time) { return {}; }
|
||||
|
||||
Optional<i64> get_time_zone_offset(StringView time_zone, AK::Time time)
|
||||
{
|
||||
if (auto maybe_time_zone = time_zone_from_string(time_zone); maybe_time_zone.has_value())
|
||||
return get_time_zone_offset(*maybe_time_zone, time);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibTimeZone/Forward.h>
|
||||
|
||||
namespace TimeZone {
|
||||
|
@ -16,4 +18,7 @@ Optional<TimeZone> time_zone_from_string(StringView time_zone);
|
|||
StringView time_zone_to_string(TimeZone time_zone);
|
||||
Optional<StringView> canonicalize_time_zone(StringView time_zone);
|
||||
|
||||
Optional<i64> get_time_zone_offset(TimeZone time_zone, AK::Time time);
|
||||
Optional<i64> get_time_zone_offset(StringView time_zone, AK::Time time);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue