2014-12-05 21:41:52 +08:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# tzset-from-unicode.org
|
|
|
|
#
|
|
|
|
# Fetch XML file containing mapping of Windows timezone keynames and countries
|
|
|
|
# per ISO 3166-1 to POSIX timezones from unicode.org.
|
|
|
|
#
|
|
|
|
# Create the table file as required by tzset.c.
|
|
|
|
#
|
|
|
|
|
2020-08-07 18:09:02 +08:00
|
|
|
ZONES_FILE="https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml"
|
2014-12-05 21:41:52 +08:00
|
|
|
|
|
|
|
echo "/*"
|
|
|
|
echo " This file gets auto-generated by the script tzmap-from-unicode.org via"
|
|
|
|
echo " a Makefile rule. To regenerate the file, just call 'make tzmap'. It"
|
|
|
|
echo " fetches the file"
|
|
|
|
echo ""
|
|
|
|
echo " ${ZONES_FILE}"
|
|
|
|
echo ""
|
|
|
|
echo " using wget and converts it into the tzmap table required by tzget.c."
|
|
|
|
echo " Regenerating might be necessary on a regular basis..."
|
|
|
|
echo ""
|
|
|
|
echo " This table maps Windows timezone keynames and countries per ISO 3166-1 to"
|
|
|
|
echo " POSIX-compatible timezone IDs."
|
|
|
|
echo ""
|
|
|
|
echo " The mapping from unicode.org is just a bit incomplete. It doesn't contain"
|
2024-03-22 04:43:10 +08:00
|
|
|
echo " some (deprecated) timezones available since Windows 8.1:"
|
2014-12-05 21:41:52 +08:00
|
|
|
echo ""
|
|
|
|
echo " Mid-Atlantic Standard Time"
|
|
|
|
echo " Kamchatka Standard Time"
|
|
|
|
echo ""
|
|
|
|
echo " as well as a few combinations which got a new Windows timezone name"
|
2024-03-22 04:43:10 +08:00
|
|
|
echo " but may still be in use somewhere..."
|
2014-12-05 21:41:52 +08:00
|
|
|
echo ""
|
2024-03-22 04:43:10 +08:00
|
|
|
echo " E. Europe Standard Time/CY"
|
2014-12-05 21:41:52 +08:00
|
|
|
echo " Eastern Standard Time/TC"
|
|
|
|
echo " Egypt Standard Time/PS"
|
|
|
|
echo " Greenwich Standard Time/EH"
|
|
|
|
echo " Hawaiian Standard Time/TK"
|
|
|
|
echo " Kaliningrad Standard Time/BY"
|
|
|
|
echo " SA Pacific Standard Time/HT "
|
|
|
|
echo " South Africa Standard Time/LY"
|
2024-03-22 04:22:49 +08:00
|
|
|
echo "*/"
|
2014-12-05 21:41:52 +08:00
|
|
|
echo ""
|
|
|
|
echo "struct"
|
|
|
|
echo "{"
|
|
|
|
echo " PCWSTR win_tzkey;"
|
|
|
|
echo " PCWSTR country;"
|
|
|
|
echo " PCWSTR posix_tzid;"
|
2014-12-05 22:39:04 +08:00
|
|
|
echo "} const tzmap[] ="
|
2014-12-05 21:41:52 +08:00
|
|
|
echo "{"
|
|
|
|
wget -O - "${ZONES_FILE}" | \
|
|
|
|
{
|
|
|
|
sed -n -e 's#territory="001"#territory=""#
|
2015-04-21 20:29:01 +08:00
|
|
|
s#Asia/Calcutta#Asia/Kolkata#
|
2014-12-05 21:41:52 +08:00
|
|
|
s#.*mapZone other=\("[^"]*"\) territory=\("[^"]*"\) type=\("[^"]*"\).*# { L\1, L\2, L\3 },#p'
|
|
|
|
echo ' { L"E. Europe Standard Time", L"CY", L"Asia/Nicosia" },'
|
|
|
|
echo ' { L"Eastern Standard Time", L"TC", L"America/Grand_Turk" },'
|
|
|
|
echo ' { L"Egypt Standard Time", L"PS", L"Asia/Gaza Asia/Hebron" },'
|
|
|
|
echo ' { L"Greenwich Standard Time", L"EH", L"Africa/El_Aaiun" },'
|
|
|
|
echo ' { L"Kaliningrad Standard Time", L"BY", L"Europe/Minsk" },'
|
|
|
|
echo ' { L"Kamchatka Standard Time", L"", L"Asia/Kamchatka" },'
|
|
|
|
echo ' { L"Hawaiian Standard Time", L"TK", L"Pacific/Fakaofo" },'
|
|
|
|
echo ' { L"Mid-Atlantic Standard Time", L"", L"Atlantic/South_Georgia" },'
|
|
|
|
echo ' { L"SA Pacific Standard Time", L"HT", L"America/Port-au-Prince" },'
|
|
|
|
echo ' { L"South Africa Standard Time", L"LY", L"Africa/Tripoli" },'
|
2021-07-29 04:18:38 +08:00
|
|
|
} | LC_ALL=C sort -d
|
2014-12-05 21:41:52 +08:00
|
|
|
echo "};"
|