Floor every zone weight at the GeoNames cutoff, refuse a table that all falls to it, and name the tzdata a drawn zone needs
This commit was merged in pull request #23.
This commit is contained in:
@@ -177,11 +177,14 @@ of them to dozens for the largest, weighted by the population GeoNames records i
|
|||||||
so `misc.territory[US].timezone` draws `America/New_York` far more often than
|
so `misc.territory[US].timezone` draws `America/New_York` far more often than
|
||||||
`America/Nome`. It links to `misc.territory`, so `misc.territory[SE].timezone` is
|
`America/Nome`. It links to `misc.territory`, so `misc.territory[SE].timezone` is
|
||||||
`Europe/Stockholm` and a drawn territory and zone agree. Its `offset` is the zone's
|
`Europe/Stockholm` and a drawn territory and zone agree. Its `offset` is the zone's
|
||||||
*standard* offset, so do not pair it with a drawn `misc.datetime`: half the year it is
|
*standard* offset, so do not pair it with a drawn `misc.datetime`: in a zone that
|
||||||
the wrong one, which is what storing a zone name avoids. There is no `UTC` row, tzdb
|
observes DST it is the wrong one half the year, which is what storing a zone name
|
||||||
|
avoids. A zone tzdb named recently — `Europe/Kyiv`, `America/Ciudad_Juarez` — is
|
||||||
|
rejected outright by a consumer resolving it against older tzdata, so where the
|
||||||
|
consumer validates the zone, pin one rather than draw it. There is no `UTC` row, tzdb
|
||||||
giving that name no territory — spell it as the text `"UTC"`. `misc.useragent` carries
|
giving that name no territory — spell it as the text `"UTC"`. `misc.useragent` carries
|
||||||
`browser`, `device` and `os` beside the string, and `misc.car` a `make` and a `model`,
|
`browser`, `device` and `os` beside the string, and `misc.car` a `make` and a `model`,
|
||||||
32 pairs until an international source replaces them.
|
until an international source replaces them.
|
||||||
|
|
||||||
ISO 3166-1 codes territories, not sovereign states, so that is what the table is
|
ISO 3166-1 codes territories, not sovereign states, so that is what the table is
|
||||||
called: Greenland and Åland have codes of their own, and `misc.territory.country`
|
called: Greenland and Åland have codes of their own, and `misc.territory.country`
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
The offset is the zone's standard offset, the first field of its Zone rule's last
|
The offset is the zone's standard offset, the first field of its Zone rule's last
|
||||||
continuation line, with a Link resolved to its target. The weight is the population
|
continuation line, with a Link resolved to its target. The weight is the population
|
||||||
GeoNames records in the zone's cities of 15,000 or more, and that threshold for a
|
GeoNames records in the zone's cities of 15,000 or more, never below that threshold,
|
||||||
zone holding none, so a drawn zone is one people live in.
|
so a drawn zone is one people live in.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import csv
|
import csv
|
||||||
@@ -87,10 +87,8 @@ def population(body):
|
|||||||
text = z.read("cities15000.txt").decode("utf-8")
|
text = z.read("cities15000.txt").decode("utf-8")
|
||||||
per = {}
|
per = {}
|
||||||
for city in csv.reader(io.StringIO(text), delimiter="\t", quoting=csv.QUOTE_NONE):
|
for city in csv.reader(io.StringIO(text), delimiter="\t", quoting=csv.QUOTE_NONE):
|
||||||
if len(city) > 17 and city[17]:
|
if len(city) > 17 and city[17] and city[14].isdigit():
|
||||||
per[city[17]] = per.get(city[17], 0) + int(city[14] or 0)
|
per[city[17]] = per.get(city[17], 0) + int(city[14])
|
||||||
if not per:
|
|
||||||
sys.exit("cities15000.txt: no city carried a timezone; the column order has moved")
|
|
||||||
return per
|
return per
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +109,7 @@ def rows(tar, territories, pop):
|
|||||||
offset = utc_offset(raw)
|
offset = utc_offset(raw)
|
||||||
if offset is None:
|
if offset is None:
|
||||||
sys.exit(f"{zone}: standard offset {raw!r} is not a ±HH:MM the table can spell")
|
sys.exit(f"{zone}: standard offset {raw!r} is not a ±HH:MM the table can spell")
|
||||||
yield {"offset": offset, "territory": territory, "weight": pop.get(zone) or FLOOR, "zone": zone}
|
yield {"offset": offset, "territory": territory, "weight": max(pop.get(zone, 0), FLOOR), "zone": zone}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -131,6 +129,8 @@ def main():
|
|||||||
linked = {r["territory"] for r in table}
|
linked = {r["territory"] for r in table}
|
||||||
if missing := shipped - linked:
|
if missing := shipped - linked:
|
||||||
sys.exit(f"no zone for {sorted(missing)}; a parent row without a child is a load error")
|
sys.exit(f"no zone for {sorted(missing)}; a parent row without a child is a load error")
|
||||||
|
if (floored := sum(1 for r in table if r["weight"] == FLOOR)) > len(table) // 2:
|
||||||
|
sys.exit(f"{floored} of {len(table)} zones fell to the floor; GeoNames' population or timezone column has moved")
|
||||||
tsv.write(a.out, COLUMNS, table)
|
tsv.write(a.out, COLUMNS, table)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+31
-31
@@ -53,7 +53,7 @@ offset territory weight zone
|
|||||||
+02:00 NA 983097 Africa/Windhoek
|
+02:00 NA 983097 Africa/Windhoek
|
||||||
-10:00 US 15000 America/Adak
|
-10:00 US 15000 America/Adak
|
||||||
-09:00 US 366200 America/Anchorage
|
-09:00 US 366200 America/Anchorage
|
||||||
-04:00 AI 2035 America/Anguilla
|
-04:00 AI 15000 America/Anguilla
|
||||||
-04:00 AG 51737 America/Antigua
|
-04:00 AG 51737 America/Antigua
|
||||||
-03:00 BR 858988 America/Araguaina
|
-03:00 BR 858988 America/Araguaina
|
||||||
-03:00 AR 11817784 America/Argentina/Buenos_Aires
|
-03:00 AR 11817784 America/Argentina/Buenos_Aires
|
||||||
@@ -108,7 +108,7 @@ offset territory weight zone
|
|||||||
-04:00 CA 122883 America/Glace_Bay
|
-04:00 CA 122883 America/Glace_Bay
|
||||||
-04:00 CA 15000 America/Goose_Bay
|
-04:00 CA 15000 America/Goose_Bay
|
||||||
-05:00 TC 27489 America/Grand_Turk
|
-05:00 TC 27489 America/Grand_Turk
|
||||||
-04:00 GD 7500 America/Grenada
|
-04:00 GD 15000 America/Grenada
|
||||||
-04:00 GP 250260 America/Guadeloupe
|
-04:00 GP 250260 America/Guadeloupe
|
||||||
-06:00 GT 7302205 America/Guatemala
|
-06:00 GT 7302205 America/Guatemala
|
||||||
-05:00 EC 11564603 America/Guayaquil
|
-05:00 EC 11564603 America/Guayaquil
|
||||||
@@ -133,11 +133,11 @@ offset territory weight zone
|
|||||||
-04:00 BO 6958595 America/La_Paz
|
-04:00 BO 6958595 America/La_Paz
|
||||||
-05:00 PE 21406340 America/Lima
|
-05:00 PE 21406340 America/Lima
|
||||||
-08:00 US 46301242 America/Los_Angeles
|
-08:00 US 46301242 America/Los_Angeles
|
||||||
-04:00 SX 1400 America/Lower_Princes
|
-04:00 SX 15000 America/Lower_Princes
|
||||||
-03:00 BR 4805317 America/Maceio
|
-03:00 BR 4805317 America/Maceio
|
||||||
-06:00 NI 2621115 America/Managua
|
-06:00 NI 2621115 America/Managua
|
||||||
-04:00 BR 3918958 America/Manaus
|
-04:00 BR 3918958 America/Manaus
|
||||||
-04:00 MF 5700 America/Marigot
|
-04:00 MF 15000 America/Marigot
|
||||||
-04:00 MQ 243860 America/Martinique
|
-04:00 MQ 243860 America/Martinique
|
||||||
-06:00 MX 1899165 America/Matamoros
|
-06:00 MX 1899165 America/Matamoros
|
||||||
-07:00 MX 2951216 America/Mazatlan
|
-07:00 MX 2951216 America/Mazatlan
|
||||||
@@ -145,11 +145,11 @@ offset territory weight zone
|
|||||||
-06:00 MX 4154924 America/Merida
|
-06:00 MX 4154924 America/Merida
|
||||||
-09:00 US 15000 America/Metlakatla
|
-09:00 US 15000 America/Metlakatla
|
||||||
-06:00 MX 61603325 America/Mexico_City
|
-06:00 MX 61603325 America/Mexico_City
|
||||||
-03:00 PM 6200 America/Miquelon
|
-03:00 PM 15000 America/Miquelon
|
||||||
-04:00 CA 381536 America/Moncton
|
-04:00 CA 381536 America/Moncton
|
||||||
-06:00 MX 9714766 America/Monterrey
|
-06:00 MX 9714766 America/Monterrey
|
||||||
-03:00 UY 2457462 America/Montevideo
|
-03:00 UY 2457462 America/Montevideo
|
||||||
-04:00 MS 1000 America/Montserrat
|
-04:00 MS 15000 America/Montserrat
|
||||||
-05:00 BS 319054 America/Nassau
|
-05:00 BS 319054 America/Nassau
|
||||||
-05:00 US 88988896 America/New_York
|
-05:00 US 88988896 America/New_York
|
||||||
-09:00 US 15000 America/Nome
|
-09:00 US 15000 America/Nome
|
||||||
@@ -157,7 +157,7 @@ offset territory weight zone
|
|||||||
-06:00 US 15000 America/North_Dakota/Beulah
|
-06:00 US 15000 America/North_Dakota/Beulah
|
||||||
-06:00 US 15000 America/North_Dakota/Center
|
-06:00 US 15000 America/North_Dakota/Center
|
||||||
-06:00 US 21382 America/North_Dakota/New_Salem
|
-06:00 US 21382 America/North_Dakota/New_Salem
|
||||||
-02:00 GL 14798 America/Nuuk
|
-02:00 GL 15000 America/Nuuk
|
||||||
-06:00 MX 50784 America/Ojinaga
|
-06:00 MX 50784 America/Ojinaga
|
||||||
-05:00 PA 1692726 America/Panama
|
-05:00 PA 1692726 America/Panama
|
||||||
-03:00 SR 454064 America/Paramaribo
|
-03:00 SR 454064 America/Paramaribo
|
||||||
@@ -178,9 +178,9 @@ offset territory weight zone
|
|||||||
-03:00 BR 129186469 America/Sao_Paulo
|
-03:00 BR 129186469 America/Sao_Paulo
|
||||||
-02:00 GL 15000 America/Scoresbysund
|
-02:00 GL 15000 America/Scoresbysund
|
||||||
-09:00 US 15000 America/Sitka
|
-09:00 US 15000 America/Sitka
|
||||||
-04:00 BL 5988 America/St_Barthelemy
|
-04:00 BL 15000 America/St_Barthelemy
|
||||||
-03:30 CA 202443 America/St_Johns
|
-03:30 CA 202443 America/St_Johns
|
||||||
-04:00 KN 12920 America/St_Kitts
|
-04:00 KN 15000 America/St_Kitts
|
||||||
-04:00 LC 45210 America/St_Lucia
|
-04:00 LC 45210 America/St_Lucia
|
||||||
-04:00 VI 70601 America/St_Thomas
|
-04:00 VI 70601 America/St_Thomas
|
||||||
-04:00 VC 48723 America/St_Vincent
|
-04:00 VC 48723 America/St_Vincent
|
||||||
@@ -189,13 +189,13 @@ offset territory weight zone
|
|||||||
-04:00 GL 15000 America/Thule
|
-04:00 GL 15000 America/Thule
|
||||||
-08:00 MX 3797218 America/Tijuana
|
-08:00 MX 3797218 America/Tijuana
|
||||||
-05:00 CA 24763654 America/Toronto
|
-05:00 CA 24763654 America/Toronto
|
||||||
-04:00 VG 8449 America/Tortola
|
-04:00 VG 15000 America/Tortola
|
||||||
-07:00 CA 6340886 America/Vancouver
|
-07:00 CA 6340886 America/Vancouver
|
||||||
-07:00 CA 28201 America/Whitehorse
|
-07:00 CA 28201 America/Whitehorse
|
||||||
-06:00 CA 922566 America/Winnipeg
|
-06:00 CA 922566 America/Winnipeg
|
||||||
-09:00 US 15000 America/Yakutat
|
-09:00 US 15000 America/Yakutat
|
||||||
+10:00 AU 15000 Antarctica/Macquarie
|
+10:00 AU 15000 Antarctica/Macquarie
|
||||||
+01:00 SJ 2368 Arctic/Longyearbyen
|
+01:00 SJ 15000 Arctic/Longyearbyen
|
||||||
+03:00 YE 6904010 Asia/Aden
|
+03:00 YE 6904010 Asia/Aden
|
||||||
+05:00 KZ 9055499 Asia/Almaty
|
+05:00 KZ 9055499 Asia/Almaty
|
||||||
+03:00 JO 4950859 Asia/Amman
|
+03:00 JO 4950859 Asia/Amman
|
||||||
@@ -277,14 +277,14 @@ offset territory weight zone
|
|||||||
+05:00 RU 15407217 Asia/Yekaterinburg
|
+05:00 RU 15407217 Asia/Yekaterinburg
|
||||||
+04:00 AM 2880620 Asia/Yerevan
|
+04:00 AM 2880620 Asia/Yerevan
|
||||||
-01:00 PT 20056 Atlantic/Azores
|
-01:00 PT 20056 Atlantic/Azores
|
||||||
-04:00 BM 902 Atlantic/Bermuda
|
-04:00 BM 15000 Atlantic/Bermuda
|
||||||
+00:00 ES 2054431 Atlantic/Canary
|
+00:00 ES 2054431 Atlantic/Canary
|
||||||
-01:00 CV 252678 Atlantic/Cape_Verde
|
-01:00 CV 252678 Atlantic/Cape_Verde
|
||||||
+00:00 FO 13200 Atlantic/Faroe
|
+00:00 FO 15000 Atlantic/Faroe
|
||||||
+00:00 PT 213794 Atlantic/Madeira
|
+00:00 PT 213794 Atlantic/Madeira
|
||||||
+00:00 IS 245356 Atlantic/Reykjavik
|
+00:00 IS 245356 Atlantic/Reykjavik
|
||||||
+00:00 SH 637 Atlantic/St_Helena
|
+00:00 SH 15000 Atlantic/St_Helena
|
||||||
-03:00 FK 2213 Atlantic/Stanley
|
-03:00 FK 15000 Atlantic/Stanley
|
||||||
+09:30 AU 1706678 Australia/Adelaide
|
+09:30 AU 1706678 Australia/Adelaide
|
||||||
+10:00 AU 5807246 Australia/Brisbane
|
+10:00 AU 5807246 Australia/Brisbane
|
||||||
+09:30 AU 17456 Australia/Broken_Hill
|
+09:30 AU 17456 Australia/Broken_Hill
|
||||||
@@ -325,7 +325,7 @@ offset territory weight zone
|
|||||||
+01:00 LU 131322 Europe/Luxembourg
|
+01:00 LU 131322 Europe/Luxembourg
|
||||||
+01:00 ES 42918247 Europe/Madrid
|
+01:00 ES 42918247 Europe/Madrid
|
||||||
+01:00 MT 141714 Europe/Malta
|
+01:00 MT 141714 Europe/Malta
|
||||||
+02:00 AX 10682 Europe/Mariehamn
|
+02:00 AX 15000 Europe/Mariehamn
|
||||||
+03:00 BY 6105410 Europe/Minsk
|
+03:00 BY 6105410 Europe/Minsk
|
||||||
+01:00 MC 48977 Europe/Monaco
|
+01:00 MC 48977 Europe/Monaco
|
||||||
+03:00 RU 69342062 Europe/Moscow
|
+03:00 RU 69342062 Europe/Moscow
|
||||||
@@ -336,7 +336,7 @@ offset territory weight zone
|
|||||||
+02:00 LV 1206422 Europe/Riga
|
+02:00 LV 1206422 Europe/Riga
|
||||||
+01:00 IT 34033666 Europe/Rome
|
+01:00 IT 34033666 Europe/Rome
|
||||||
+04:00 RU 3546813 Europe/Samara
|
+04:00 RU 3546813 Europe/Samara
|
||||||
+01:00 SM 4500 Europe/San_Marino
|
+01:00 SM 15000 Europe/San_Marino
|
||||||
+01:00 BA 1905798 Europe/Sarajevo
|
+01:00 BA 1905798 Europe/Sarajevo
|
||||||
+04:00 RU 1705529 Europe/Saratov
|
+04:00 RU 1705529 Europe/Saratov
|
||||||
+03:00 UA 1620906 Europe/Simferopol
|
+03:00 UA 1620906 Europe/Simferopol
|
||||||
@@ -346,8 +346,8 @@ offset territory weight zone
|
|||||||
+02:00 EE 1106943 Europe/Tallinn
|
+02:00 EE 1106943 Europe/Tallinn
|
||||||
+01:00 AL 1629643 Europe/Tirane
|
+01:00 AL 1629643 Europe/Tirane
|
||||||
+04:00 RU 814189 Europe/Ulyanovsk
|
+04:00 RU 814189 Europe/Ulyanovsk
|
||||||
+01:00 LI 5197 Europe/Vaduz
|
+01:00 LI 15000 Europe/Vaduz
|
||||||
+01:00 VA 829 Europe/Vatican
|
+01:00 VA 15000 Europe/Vatican
|
||||||
+01:00 AT 5274040 Europe/Vienna
|
+01:00 AT 5274040 Europe/Vienna
|
||||||
+02:00 LT 2103133 Europe/Vilnius
|
+02:00 LT 2103133 Europe/Vilnius
|
||||||
+03:00 RU 1837053 Europe/Volgograd
|
+03:00 RU 1837053 Europe/Volgograd
|
||||||
@@ -356,10 +356,10 @@ offset territory weight zone
|
|||||||
+01:00 CH 3461664 Europe/Zurich
|
+01:00 CH 3461664 Europe/Zurich
|
||||||
+03:00 MG 6115943 Indian/Antananarivo
|
+03:00 MG 6115943 Indian/Antananarivo
|
||||||
+06:00 IO 15000 Indian/Chagos
|
+06:00 IO 15000 Indian/Chagos
|
||||||
+07:00 CX 1355 Indian/Christmas
|
+07:00 CX 15000 Indian/Christmas
|
||||||
+06:30 CC 120 Indian/Cocos
|
+06:30 CC 15000 Indian/Cocos
|
||||||
+03:00 KM 118353 Indian/Comoro
|
+03:00 KM 118353 Indian/Comoro
|
||||||
+05:00 TF 45 Indian/Kerguelen
|
+05:00 TF 15000 Indian/Kerguelen
|
||||||
+04:00 SC 22881 Indian/Mahe
|
+04:00 SC 22881 Indian/Mahe
|
||||||
+05:00 MV 103693 Indian/Maldives
|
+05:00 MV 103693 Indian/Maldives
|
||||||
+04:00 MU 701493 Indian/Mauritius
|
+04:00 MU 701493 Indian/Mauritius
|
||||||
@@ -373,7 +373,7 @@ offset territory weight zone
|
|||||||
-06:00 CL 15000 Pacific/Easter
|
-06:00 CL 15000 Pacific/Easter
|
||||||
+11:00 VU 35901 Pacific/Efate
|
+11:00 VU 35901 Pacific/Efate
|
||||||
+12:00 FJ 334403 Pacific/Fiji
|
+12:00 FJ 334403 Pacific/Fiji
|
||||||
+12:00 TV 6320 Pacific/Funafuti
|
+12:00 TV 15000 Pacific/Funafuti
|
||||||
-06:00 EC 15000 Pacific/Galapagos
|
-06:00 EC 15000 Pacific/Galapagos
|
||||||
-09:00 PF 15000 Pacific/Gambier
|
-09:00 PF 15000 Pacific/Gambier
|
||||||
+11:00 SB 194707 Pacific/Guadalcanal
|
+11:00 SB 194707 Pacific/Guadalcanal
|
||||||
@@ -385,18 +385,18 @@ offset territory weight zone
|
|||||||
+12:00 MH 15000 Pacific/Kwajalein
|
+12:00 MH 15000 Pacific/Kwajalein
|
||||||
+12:00 MH 45701 Pacific/Majuro
|
+12:00 MH 45701 Pacific/Majuro
|
||||||
-09:30 PF 15000 Pacific/Marquesas
|
-09:30 PF 15000 Pacific/Marquesas
|
||||||
+12:00 NR 1100 Pacific/Nauru
|
+12:00 NR 15000 Pacific/Nauru
|
||||||
-11:00 NU 624 Pacific/Niue
|
-11:00 NU 15000 Pacific/Niue
|
||||||
+11:00 NF 880 Pacific/Norfolk
|
+11:00 NF 15000 Pacific/Norfolk
|
||||||
+11:00 NC 137086 Pacific/Noumea
|
+11:00 NC 137086 Pacific/Noumea
|
||||||
-11:00 AS 11500 Pacific/Pago_Pago
|
-11:00 AS 15000 Pacific/Pago_Pago
|
||||||
+09:00 PW 15000 Pacific/Palau
|
+09:00 PW 15000 Pacific/Palau
|
||||||
-08:00 PN 46 Pacific/Pitcairn
|
-08:00 PN 15000 Pacific/Pitcairn
|
||||||
+11:00 FM 6942 Pacific/Pohnpei
|
+11:00 FM 15000 Pacific/Pohnpei
|
||||||
+10:00 PG 588589 Pacific/Port_Moresby
|
+10:00 PG 588589 Pacific/Port_Moresby
|
||||||
-10:00 CK 13373 Pacific/Rarotonga
|
-10:00 CK 15000 Pacific/Rarotonga
|
||||||
+10:00 MP 48220 Pacific/Saipan
|
+10:00 MP 48220 Pacific/Saipan
|
||||||
-10:00 PF 81958 Pacific/Tahiti
|
-10:00 PF 81958 Pacific/Tahiti
|
||||||
+12:00 KI 40311 Pacific/Tarawa
|
+12:00 KI 40311 Pacific/Tarawa
|
||||||
+13:00 TO 22400 Pacific/Tongatapu
|
+13:00 TO 22400 Pacific/Tongatapu
|
||||||
+12:00 WF 1200 Pacific/Wallis
|
+12:00 WF 15000 Pacific/Wallis
|
||||||
|
|||||||
|
Reference in New Issue
Block a user