From cc7187cd861f0e92726a010bf0af5e1305d3601d Mon Sep 17 00:00:00 2001 From: Michael Lenaghan Date: Wed, 26 Jul 2023 16:04:39 -0400 Subject: [PATCH] Change the timezones to the match the city portion of the canonical IANA Zone IDs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This renames the following Zone IDs: * Beijing -> Shangai * Boulder -> Denver * GST -> Los_Angeles * India -> Kolkata * Israel -> Jerusalem * Japan -> Tokyo The new names are the *city* portion of the canonical Zone ID for each zone. (See https://nodatime.org/TimeZones for a complete list of canonical Zone IDs from IANA 2023c.) The most important change is “GST -> Los_Angeles”. In the code, “GST” was taken to mean “Google Standard Time”, but it already means something else: “Gulf Standard Time” (https://www.timeanddate.com/time/zones/gst). In addition: * The India zoneinfo file wasn’t YOINKed; now it is, under the name Kolkata * The Melbourne zoneinfo file *was* YOINKed; it was deleted in favor of an already-existing un-YOINKed Sydney file * The Singapore zoneinfo file wasn’t YOINKed; it was deleted (Melbourne is in the same timezone as Sydney. Singapore is in the same timezone as Shanghai. But note that “same timezone” is misleading, since *when* the standard time/daylight savings time shift happens is a political question.) Finally, the offsets in the docs were a mixture of standard time and daylight savings time. Now both offsets are given. The first is always the standard time offset. The second, if applicable, is the daylight savings offset. Among other things, that clarifies which timezones do and do not have daylight savings. --- libc/time/localtime.c | 13 +++++----- test/libc/time/strftime_test.c | 10 ++++---- third_party/python/Lib/test/test_time.py | 14 +++++------ tool/net/definitions.lua | 30 +++++++++++------------ tool/net/help.txt | 30 +++++++++++------------ usr/share/zoneinfo/{Boulder => Denver} | Bin usr/share/zoneinfo/{Israel => Jerusalem} | Bin usr/share/zoneinfo/{India => Kolkata} | Bin usr/share/zoneinfo/{GST => Los_Angeles} | Bin usr/share/zoneinfo/Melbourne | Bin 2223 -> 0 bytes usr/share/zoneinfo/{Beijing => Shanghai} | Bin usr/share/zoneinfo/Singapore | Bin 424 -> 0 bytes usr/share/zoneinfo/{Japan => Tokyo} | Bin 13 files changed, 49 insertions(+), 48 deletions(-) rename usr/share/zoneinfo/{Boulder => Denver} (100%) rename usr/share/zoneinfo/{Israel => Jerusalem} (100%) rename usr/share/zoneinfo/{India => Kolkata} (100%) rename usr/share/zoneinfo/{GST => Los_Angeles} (100%) delete mode 100644 usr/share/zoneinfo/Melbourne rename usr/share/zoneinfo/{Beijing => Shanghai} (100%) delete mode 100644 usr/share/zoneinfo/Singapore rename usr/share/zoneinfo/{Japan => Tokyo} (100%) diff --git a/libc/time/localtime.c b/libc/time/localtime.c index 8d6709afc..da9492ae2 100644 --- a/libc/time/localtime.c +++ b/libc/time/localtime.c @@ -20,18 +20,19 @@ STATIC_YOINK("zipos"); STATIC_YOINK("usr/share/zoneinfo/"); STATIC_YOINK("usr/share/zoneinfo/Anchorage"); -STATIC_YOINK("usr/share/zoneinfo/Beijing"); STATIC_YOINK("usr/share/zoneinfo/Berlin"); -STATIC_YOINK("usr/share/zoneinfo/Boulder"); STATIC_YOINK("usr/share/zoneinfo/Chicago"); +STATIC_YOINK("usr/share/zoneinfo/Denver"); STATIC_YOINK("usr/share/zoneinfo/GMT"); -STATIC_YOINK("usr/share/zoneinfo/GST"); STATIC_YOINK("usr/share/zoneinfo/Honolulu"); -STATIC_YOINK("usr/share/zoneinfo/Israel"); -STATIC_YOINK("usr/share/zoneinfo/Japan"); +STATIC_YOINK("usr/share/zoneinfo/Jerusalem"); +STATIC_YOINK("usr/share/zoneinfo/Kolkata"); +STATIC_YOINK("usr/share/zoneinfo/Los_Angeles"); STATIC_YOINK("usr/share/zoneinfo/London"); -STATIC_YOINK("usr/share/zoneinfo/Melbourne"); STATIC_YOINK("usr/share/zoneinfo/New_York"); +STATIC_YOINK("usr/share/zoneinfo/Shanghai"); +STATIC_YOINK("usr/share/zoneinfo/Sydney"); +STATIC_YOINK("usr/share/zoneinfo/Tokyo"); STATIC_YOINK("usr/share/zoneinfo/UTC"); // clang-format off diff --git a/test/libc/time/strftime_test.c b/test/libc/time/strftime_test.c index 18684fb0e..4891a9ede 100644 --- a/test/libc/time/strftime_test.c +++ b/test/libc/time/strftime_test.c @@ -24,7 +24,7 @@ #include "libc/time/time.h" textstartup static void strftime_test_init(void) { - setenv("TZ", "GST", true); + setenv("TZ", "Los_Angeles", true); } const void *const strftime_test_ctor[] initarray = {strftime_test_init}; @@ -58,20 +58,20 @@ TEST(strftime_100, rfc822_ShakaZuluTime) { FormatTime("%a, %d %b %y %T %z", gmtime(&t))); } -TEST(strftime_201, iso8601_GoogleStandardTime) { +TEST(strftime_201, iso8601_LosAngeles) { int64_t t = 0x5cd04d0e; - ASSERT_STREQ("GST", getenv("TZ")); + ASSERT_STREQ("Los_Angeles", getenv("TZ")); ASSERT_STREQ("2019-05-06T08:04:46PDT", FormatTime("%Y-%m-%dT%H:%M:%S%Z", localtime(&t))); } -TEST(strftime_201, rfc2822_GoogleStandardTime) { +TEST(strftime_201, rfc2822_LosAngeles) { int64_t t = 0x5cd04d0e; ASSERT_STREQ("Mon, 06 May 2019 08:04:46 -0700", FormatTime("%a, %d %b %Y %T %z", localtime(&t))); } -TEST(strftime_201, rfc822_GoogleStandardTime) { +TEST(strftime_201, rfc822_LosAngeles) { int64_t t = 0x5cd04d0e; ASSERT_STREQ("Mon, 06 May 19 08:04:46 -0700", FormatTime("%a, %d %b %y %T %z", localtime(&t))); diff --git a/third_party/python/Lib/test/test_time.py b/third_party/python/Lib/test/test_time.py index 44e82ebd5..b9b5e08a5 100644 --- a/third_party/python/Lib/test/test_time.py +++ b/third_party/python/Lib/test/test_time.py @@ -295,20 +295,20 @@ class TimeTestCase(unittest.TestCase): # http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html # They are also documented in the tzset(3) man page on most Unix # systems. - # eastern = 'EST+05EDT,M4.1.0,M10.5.0' # [jart] wut - # victoria = 'AEST-10AEDT-11,M10.5.0,M3.5.0' + # new_york = 'EST+05EDT,M4.1.0,M10.5.0' # [jart] wut + # sydney = 'AEST-10AEDT-11,M10.5.0,M3.5.0' # utc='UTC+0' utc = 'UTC' - eastern = 'New_York' - victoria = 'Melbourne' + new_york = 'New_York' + sydney = 'Sydney' org_TZ = environ.get('TZ',None) try: # Make sure we can switch to UTC time and results are correct # Note that unknown timezones default to UTC. # Note that altzone is undefined in UTC, as there is no DST - environ['TZ'] = eastern + environ['TZ'] = new_york time.tzset() environ['TZ'] = utc time.tzset() @@ -320,7 +320,7 @@ class TimeTestCase(unittest.TestCase): self.assertEqual(time.localtime(xmas2002).tm_isdst, 0) # Make sure we can switch to US/Eastern - environ['TZ'] = eastern + environ['TZ'] = new_york time.tzset() self.assertNotEqual(time.gmtime(xmas2002), time.localtime(xmas2002)) self.assertEqual(time.tzname, ('EST', 'EDT')) @@ -332,7 +332,7 @@ class TimeTestCase(unittest.TestCase): self.assertEqual(len(time.tzname), 2) # Now go to the southern hemisphere. - environ['TZ'] = victoria + environ['TZ'] = sydney time.tzset() self.assertNotEqual(time.gmtime(xmas2002), time.localtime(xmas2002)) diff --git a/tool/net/definitions.lua b/tool/net/definitions.lua index 37e842fc6..17d5119ce 100644 --- a/tool/net/definitions.lua +++ b/tool/net/definitions.lua @@ -7071,21 +7071,21 @@ function unix.gmtime(unixts) end --- --- Your redbean ships with a subset of the time zone database. --- ---- - `/zip/usr/share/zoneinfo/Honolulu` Z-10 ---- - `/zip/usr/share/zoneinfo/Anchorage` Z -9 ---- - `/zip/usr/share/zoneinfo/GST` Z -8 ---- - `/zip/usr/share/zoneinfo/Boulder` Z -6 ---- - `/zip/usr/share/zoneinfo/Chicago` Z -5 ---- - `/zip/usr/share/zoneinfo/New_York` Z -4 ---- - `/zip/usr/share/zoneinfo/UTC` Z +0 ---- - `/zip/usr/share/zoneinfo/GMT` Z +0 ---- - `/zip/usr/share/zoneinfo/London` Z +1 ---- - `/zip/usr/share/zoneinfo/Berlin` Z +2 ---- - `/zip/usr/share/zoneinfo/Israel` Z +3 ---- - `/zip/usr/share/zoneinfo/India` Z +5 ---- - `/zip/usr/share/zoneinfo/Beijing` Z +8 ---- - `/zip/usr/share/zoneinfo/Japan` Z +9 ---- - `/zip/usr/share/zoneinfo/Sydney` Z+10 +--- - `/zip/usr/share/zoneinfo/Honolulu` Z-10 +--- - `/zip/usr/share/zoneinfo/Anchorage` Z-09/-08 +--- - `/zip/usr/share/zoneinfo/Los_Angeles` Z-08/-07 +--- - `/zip/usr/share/zoneinfo/Denver` Z-07/-06 +--- - `/zip/usr/share/zoneinfo/Chicago` Z-06/-05 +--- - `/zip/usr/share/zoneinfo/New_York` Z-05/-04 +--- - `/zip/usr/share/zoneinfo/UTC` Z+00 +--- - `/zip/usr/share/zoneinfo/GMT` Z+00 +--- - `/zip/usr/share/zoneinfo/London` Z+00/+01 +--- - `/zip/usr/share/zoneinfo/Berlin` Z+01/+02 +--- - `/zip/usr/share/zoneinfo/Jerusalem` Z+02/+03 +--- - `/zip/usr/share/zoneinfo/Kolkata` Z+05:30 +--- - `/zip/usr/share/zoneinfo/Shanghai` Z+08 +--- - `/zip/usr/share/zoneinfo/Tokyo` Z+09 +--- - `/zip/usr/share/zoneinfo/Sydney` Z+10/+11 --- --- You can control which timezone is used using the `TZ` environment --- variable. If your time zone isn't included in the above list, you diff --git a/tool/net/help.txt b/tool/net/help.txt index 84db6da0c..9ffdc83bb 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -4586,21 +4586,21 @@ UNIX MODULE Your redbean ships with a subset of the time zone database. - - `/zip/usr/share/zoneinfo/Honolulu` Z-10 - - `/zip/usr/share/zoneinfo/Anchorage` Z -9 - - `/zip/usr/share/zoneinfo/GST` Z -8 - - `/zip/usr/share/zoneinfo/Boulder` Z -6 - - `/zip/usr/share/zoneinfo/Chicago` Z -5 - - `/zip/usr/share/zoneinfo/New_York` Z -4 - - `/zip/usr/share/zoneinfo/UTC` Z +0 - - `/zip/usr/share/zoneinfo/GMT` Z +0 - - `/zip/usr/share/zoneinfo/London` Z +1 - - `/zip/usr/share/zoneinfo/Berlin` Z +2 - - `/zip/usr/share/zoneinfo/Israel` Z +3 - - `/zip/usr/share/zoneinfo/India` Z +5 - - `/zip/usr/share/zoneinfo/Beijing` Z +8 - - `/zip/usr/share/zoneinfo/Japan` Z +9 - - `/zip/usr/share/zoneinfo/Sydney` Z+10 + - `/zip/usr/share/zoneinfo/Honolulu` Z-10 + - `/zip/usr/share/zoneinfo/Anchorage` Z-09/-08 + - `/zip/usr/share/zoneinfo/Los_Angeles` Z-08/-07 + - `/zip/usr/share/zoneinfo/Denver` Z-07/-06 + - `/zip/usr/share/zoneinfo/Chicago` Z-06/-05 + - `/zip/usr/share/zoneinfo/New_York` Z-05/-04 + - `/zip/usr/share/zoneinfo/UTC` Z+00 + - `/zip/usr/share/zoneinfo/GMT` Z+00 + - `/zip/usr/share/zoneinfo/London` Z+00/+01 + - `/zip/usr/share/zoneinfo/Berlin` Z+01/+02 + - `/zip/usr/share/zoneinfo/Jerusalem` Z+02/+03 + - `/zip/usr/share/zoneinfo/Kolkata` Z+05:30 + - `/zip/usr/share/zoneinfo/Shanghai` Z+08 + - `/zip/usr/share/zoneinfo/Tokyo` Z+09 + - `/zip/usr/share/zoneinfo/Sydney` Z+10/+11 You can control which timezone is used using the `TZ` environment variable. If your time zone isn't included in the above list, you diff --git a/usr/share/zoneinfo/Boulder b/usr/share/zoneinfo/Denver similarity index 100% rename from usr/share/zoneinfo/Boulder rename to usr/share/zoneinfo/Denver diff --git a/usr/share/zoneinfo/Israel b/usr/share/zoneinfo/Jerusalem similarity index 100% rename from usr/share/zoneinfo/Israel rename to usr/share/zoneinfo/Jerusalem diff --git a/usr/share/zoneinfo/India b/usr/share/zoneinfo/Kolkata similarity index 100% rename from usr/share/zoneinfo/India rename to usr/share/zoneinfo/Kolkata diff --git a/usr/share/zoneinfo/GST b/usr/share/zoneinfo/Los_Angeles similarity index 100% rename from usr/share/zoneinfo/GST rename to usr/share/zoneinfo/Los_Angeles diff --git a/usr/share/zoneinfo/Melbourne b/usr/share/zoneinfo/Melbourne deleted file mode 100644 index ec8dfe038c2d10aed29763ef8f664c8f0cd35c8c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2223 zcmds%TTGU99LK+}!U#&qa>zjmwG<3Fs2G%z2S7+Ml$T?v1c+h>UqA&b>6eGmMM_$m z%$Oq0=%T`CO>-<_wXs5Ebj^bSvMs!v;XH=7j0d1+xk3v{-0;>p7*_azaM{j zZOsDxgJAawHym;|&y&p^?Q36eZ|{x!dC>o^1_w$4=g$<|P*+CaLPvv!TVete0~r=H zX}W?7Vl4RAbPGwoVIf~cTWI)Y3w`f*3%lBHx1Na7ZC`z>NzKbt zW}oh8+OIofPiksuji&ywPZ8<4inwyZB4<`xdm<~O}*Nj-IzydzU7M+z-fQc53yR8m;LnQU1|ft!>HB!;SM)5Gb;B6*;!P;65u{7H|HP zC@YE!v*PgUR($g(E4g~fN-tlqvf(}}?>lXeoV}<=-x$({why%Ng>G$X>QKej!+NZA zuPSpJRFz(>>i8mUj?7WblsenutF$e@6x!C&EUW!2&9?Q=vB%$;W>1{F#h!d=+@7)@ zY*>25yE9|-YbvD8G*EKQdKX6Gc-@8Auj-B=eNiTLN^zYAW^8H$#oyAe;=QW>? zQ~rP7NvnI!+sQTW8`4cjL&Skd%x*lp?O^uf*=-23Bg~dCd%|prpJP{;Z2|l8>^6qk znP;~(%-%e^&0%(j*&eVzV1vL8fh_`i1U3om64)lNPtR_nz)n58tz!1-*=-iHThDI0 znEhfljM*_}%a}a_o5t)K*fy|lVB^5ffvp33_v|(g?B286KCpkF0hkV8T7c;RrU^h7 zFm1r}0n-RfCorwR^un`i2BsUHT{|%Sz%&HY5uhbNPk^QXT>;tx^aaxxpfi}(V0wdT z4$vLXu0241fCd2_0$K$02xt<}C7?|}pD>NWbPCfdOs_D_!gR~CYZsUB*HECNKudw10!;rh`G9q1pkq1OF0Ljb>1|bH9x(N&t3=9Pg z3^G2xAq>GltZiTp!bS!l(ilWq0