mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
317c8bc312
I took one canonical IANA zone ID from each of the different colored regions in this article, except those that do not observe DST and do not have a Google office. See the "Time in Europe" Wikipedia article. As to which canonical ID to use, this was somewhat arbitrary. Brussels was obvious, as the de facto capital of the EU. For the rest, I mostly just went with lexicographic ordering of the most recognizable options. I've sorted the American zones. This Keeps the U.S. ones together but does everything alphabetically otherwise. I've added the remaining Canadian zones These have DST (and Newfoundland is off by a half- hour from a UTC interval) so they cannot use Etc/. The Pacific/ zones are sort of sorted. The Chathan Islands have been added. This is the last of the zones I believe with a non-integer hour offset from UTC.
152 lines
3.1 KiB
Python
152 lines
3.1 KiB
Python
# Thank you Alejandro Zeise for collecting this information
|
|
# https://gist.github.com/alejzeis/ad5827eb14b5c22109ba652a1a267af5
|
|
|
|
SUPPORTED = set((
|
|
'Africa/Algiers',
|
|
'Africa/Cairo',
|
|
'Africa/Johannesburg',
|
|
'Africa/Lagos',
|
|
'Africa/Nairobi',
|
|
'America/Anchorage',
|
|
'America/Argentina/Buenos_Aires',
|
|
'America/Bogota',
|
|
'America/Chicago',
|
|
'America/Denver',
|
|
'America/Lima',
|
|
'America/Los_Angeles',
|
|
'America/Mexico_City',
|
|
'America/New_York',
|
|
'America/Phoenix',
|
|
'America/Santiago',
|
|
'America/Sao_Paulo',
|
|
'Asia/Bangkok',
|
|
'Asia/Dhaka',
|
|
'Asia/Dubai',
|
|
'Asia/Hong_Kong',
|
|
'Asia/Jakarta',
|
|
'Asia/Jerusalem',
|
|
'Asia/Kabul',
|
|
'Asia/Karachi',
|
|
'Asia/Kolkata',
|
|
'Asia/Manila',
|
|
'Asia/Seoul',
|
|
'Asia/Shanghai',
|
|
'Asia/Singapore',
|
|
'Asia/Taipei',
|
|
'Asia/Tehran',
|
|
'Asia/Tokyo',
|
|
'Australia/Adelaide',
|
|
'Australia/Brisbane',
|
|
'Australia/Melbourne',
|
|
'Australia/Perth',
|
|
'Australia/Sydney',
|
|
'CET',
|
|
'CST6CDT',
|
|
'EET',
|
|
'EST',
|
|
'EST5EDT',
|
|
'Etc/GMT',
|
|
'Etc/GMT+1',
|
|
'Etc/GMT+10',
|
|
'Etc/GMT+11',
|
|
'Etc/GMT+12',
|
|
'Etc/GMT+2',
|
|
'Etc/GMT+3',
|
|
'Etc/GMT+4',
|
|
'Etc/GMT+5',
|
|
'Etc/GMT+6',
|
|
'Etc/GMT+7',
|
|
'Etc/GMT+8',
|
|
'Etc/GMT+9',
|
|
'Etc/GMT-1',
|
|
'Etc/GMT-10',
|
|
'Etc/GMT-11',
|
|
'Etc/GMT-12',
|
|
'Etc/GMT-13',
|
|
'Etc/GMT-14',
|
|
'Etc/GMT-2',
|
|
'Etc/GMT-3',
|
|
'Etc/GMT-4',
|
|
'Etc/GMT-5',
|
|
'Etc/GMT-6',
|
|
'Etc/GMT-7',
|
|
'Etc/GMT-8',
|
|
'Etc/GMT-9',
|
|
'Etc/UTC',
|
|
'Europe/Brussels',
|
|
'Europe/Bucharest',
|
|
'Europe/Dublin',
|
|
'Europe/Istanbul',
|
|
'GMT',
|
|
'HST',
|
|
'MET',
|
|
'MST',
|
|
'MST7MDT',
|
|
'PST8PDT',
|
|
'Pacific/Auckland',
|
|
'Pacific/Fiji',
|
|
'Pacific/Guam',
|
|
'Pacific/Honolulu',
|
|
'Pacific/Port_Moresby',
|
|
'WET',
|
|
))
|
|
|
|
import re
|
|
import os
|
|
import subprocess
|
|
|
|
NAMES = set()
|
|
ZONES = set()
|
|
SUPERFLUOUS = set()
|
|
TABLE1 = []
|
|
TABLE2 = []
|
|
|
|
with open("/home/jart/scratch/windows-timezone-mappings.csv") as f:
|
|
for line in f:
|
|
line = line.strip()
|
|
if not line:
|
|
break
|
|
name, what, zone = line.split(',')
|
|
if name in NAMES:
|
|
continue
|
|
ZZ = zone.split() # has superfluous zones
|
|
ZZ = [z for z in ZZ if z in SUPPORTED] + [z for z in ZZ if z not in SUPPORTED]
|
|
zone = ZZ[0]
|
|
rest = ZZ[1:]
|
|
NAMES.add(name)
|
|
ZONES.add(ZZ[0])
|
|
SUPERFLUOUS |= set(rest)
|
|
os.environ['TZ'] = zone
|
|
p = subprocess.Popen(['date', '+%z@%Z'], stdout=subprocess.PIPE)
|
|
z, Z = p.stdout.read().decode('utf-8').strip().split('@')
|
|
print("%-35s %-5s %-10s %-10s %-30s" % (name, what, z, Z, zone))
|
|
if zone in SUPPORTED:
|
|
TABLE1.append((name, zone, z, Z))
|
|
else:
|
|
TABLE2.append((name, zone, z, Z))
|
|
|
|
print()
|
|
TABLE1.sort()
|
|
TABLE2.sort()
|
|
for k, v, z, Z in TABLE1:
|
|
print('{"%s", "%s"}, // %s %s' % (k, v, z, Z))
|
|
print('#ifdef EMBED_EVERY_TIME_ZONE')
|
|
for k, v, z, Z in TABLE2:
|
|
print('{"%s", "%s"}, // %s %s' % (k, v, z, Z))
|
|
print('#endif')
|
|
|
|
# print()
|
|
# TABLE.sort(key=lambda x: (int(x[2]), x[1]))
|
|
# for k, v, z, Z in TABLE:
|
|
# if re.search(r'[A-Z]', Z):
|
|
# Z = ' ' + Z
|
|
# else:
|
|
# Z = ''
|
|
# print('__static_yoink("usr/share/zoneinfo/%s"); // %s%s (%s)' % (v, z, Z, k))
|
|
# print('#ifdef EMBED_EVERY_TIME_ZONE')
|
|
# print('#endif')
|
|
|
|
# print()
|
|
# SUPERFLUOUS -= ZONES
|
|
# for z in SUPERFLUOUS:
|
|
# print(z)
|