From 09c0324880f0a91c914aad07e507d75ef74b03b2 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 10 Jan 2022 16:56:09 -0500 Subject: [PATCH] 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". --- .../LibTimeZone/GenerateTimeZoneData.cpp | 177 ++++++++++++++---- Tests/LibTimeZone/TestTimeZone.cpp | 42 +++++ Userland/Libraries/LibTimeZone/TimeZone.cpp | 9 + Userland/Libraries/LibTimeZone/TimeZone.h | 5 + 4 files changed, 199 insertions(+), 34 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp index 726e4ee8b4..1f1b093741 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp @@ -5,6 +5,7 @@ */ #include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common. +#include #include #include #include @@ -15,45 +16,61 @@ namespace { -struct Time { - i8 hour { 0 }; - u8 minute { 0 }; - u8 second { 0 }; -}; - struct DateTime { u16 year { 0 }; Optional month; + Optional day; + Optional last_weekday; Optional after_weekday; - Optional day; - Optional