| index 717bebd..bc267cf 100644 | ||
| --- a/README.md | ||
| +++ b/README.md | ||
| @@ -16,7 +16,7 @@ make win64 # MinGW-w64 static PE -> ./plugin_time.exe | ||
| 16 | 16 | make macos # Apple clang (on macOS) -> ./plugin_time |
| 17 | 17 | make tzdata # regenerate src/tzdata.h from the host tz database |
| 18 | 18 | make ui # regenerate src/ui_html.h from src/ui.html |
| 19 | -make test # offline suite (190+ assertions) | |
| 19 | +make test # offline suite (200+ assertions) | |
| 20 | 20 | python3 tests/e2e.py # Playwright viewport suite (1440 / 1024 / 390, dark + light) |
| 21 | 21 | ``` |
| 22 | 22 | |
| @@ -37,7 +37,16 @@ about. | ||
| 37 | 37 | (`Africa/Casablanca`) and redesigned rules (`Asia/Hebron`) are exact rather |
| 38 | 38 | than approximated; |
| 39 | 39 | * each zone's own POSIX TZ footer string, used only **beyond** the last embedded |
| 40 | - transition, which is exactly what a host does when it runs out of table. | |
| 40 | + transition, which is exactly what a host does when it runs out of table; | |
| 41 | +* the **142** Windows timezone ids from CLDR (`windowsZones.xml`), so a Windows | |
| 42 | + node reports `New Zealand Standard Time` as `Pacific/Auckland` instead of | |
| 43 | + guessing from an offset — `plugin_time --win-tz "New Zealand Standard Time"` | |
| 44 | + answers for a Windows box from any platform. | |
| 45 | + | |
| 46 | +The Windows name comes from `GetDynamicTimeZoneInformation().TimeZoneKeyName`, | |
| 47 | +which is the invariant registry id. `GetTimeZoneInformation().StandardName` is | |
| 48 | +localised (`Neuseeland Normalzeit` on a German Windows) and matches no CLDR row, | |
| 49 | +so it is only a fallback. | |
| 41 | 50 | |
| 42 | 51 | Regeneration is deterministic: the same tz database produces the same bytes, and |
| 43 | 52 | `tests/run.sh` re-runs the generator and compares. |
| @@ -64,7 +73,7 @@ BotCloud container: `/workspace/.scorpiox/plugins/plugin_time`. | ||
| 64 | 73 | | **MCP tool provider** | `--mcp` | newline-delimited **JSON-RPC 2.0 over stdio** — `initialize`, `tools/list`, `tools/call`, `ping` | |
| 65 | 74 | | API | `?action=...`, `?format=json`, or any `POST` | `application/json; charset=utf-8` | |
| 66 | 75 | | UI | plain `GET` (`?embed=1` aware) | the World Clock page, `text/html` | |
| 67 | -| Info | `--version`, `--help`, `--schema` | id + version, usage, the tool schemas | | |
| 76 | +| Info | `--version`, `--help`, `--schema`, `--win-tz <id>` | id + version, usage, the tool schemas, a Windows id -> IANA key | | |
| 68 | 77 | |
| 69 | 78 | Modes 3 and 4 sit behind `require_node_auth()`: `X-Bot-Password`, |
| 70 | 79 | `Authorization: Bearer <pwd>`, or `?pwd=`. With `BOT_PASSWORD` unset the check is |
| index b66deb1..8f500b4 100644 | ||
| --- a/docs/usage.md | ||
| +++ b/docs/usage.md | ||
| @@ -93,7 +93,22 @@ directly. The clock, the converter and the world-clock table all call the tools | ||
| 93 | 93 | every second, so what you see is what an agent gets. Add zones with the picker; |
| 94 | 94 | the list is remembered in your browser. |
| 95 | 95 | |
| 96 | -## 8. Updating the database | |
| 96 | +## 8. Windows nodes | |
| 97 | + | |
| 98 | +A Windows box has no tzdata. Its own zone name comes from the registry and is | |
| 99 | +mapped through CLDR to the same IANA key every other platform reports, so | |
| 100 | +`get_current_time` with no arguments answers `Pacific/Auckland` there too - not | |
| 101 | +"UTC+12" and not a guess. | |
| 102 | + | |
| 103 | +The whole map is embedded on every platform, so you can check a mapping without a | |
| 104 | +Windows machine: | |
| 105 | + | |
| 106 | +```sh | |
| 107 | +plugin_time --win-tz "New Zealand Standard Time" # Pacific/Auckland | |
| 108 | +plugin_time --win-tz "Eastern Standard Time" # America/New_York | |
| 109 | +``` | |
| 110 | + | |
| 111 | +## 9. Updating the database | |
| 97 | 112 | |
| 98 | 113 | ```sh |
| 99 | 114 | make tzdata # regenerate src/tzdata.h from /usr/share/zoneinfo |
| index 9442641..57d977e 100644 | ||
| --- a/src/plugin_time.c | ||
| +++ b/src/plugin_time.c | ||
| @@ -670,6 +670,7 @@ static void print_help(void) | ||
| 670 | 670 | " --meta print plugin discovery metadata and exit\n" |
| 671 | 671 | " --mcp serve MCP JSON-RPC 2.0 over stdin/stdout\n" |
| 672 | 672 | " --schema print the tools/list array\n" |
| 673 | + " --win-tz <id> resolve a Windows timezone id to its IANA key\n" | |
| 673 | 674 | " --version print version\n" |
| 674 | 675 | " (no args) CGI: World Clock page + ?action= API\n\n" |
| 675 | 676 | "tools: ", PLUGIN_ID, PLUGIN_VER); |
| @@ -696,6 +697,20 @@ int main(int argc, char **argv) | ||
| 696 | 697 | free(t); |
| 697 | 698 | return 0; |
| 698 | 699 | } |
| 700 | + if (strcmp(argv[i], "--win-tz") == 0) { | |
| 701 | + /* Diagnostic: what does a Windows node's registry name resolve to? | |
| 702 | + * The mapping is embedded on every platform, so this answers for a | |
| 703 | + * Windows box from a Linux one. */ | |
| 704 | + const tz_zone *z = (i + 1 < argc) ? tz_find_windows(argv[i + 1]) : NULL; | |
| 705 | + if (!z) { | |
| 706 | + fprintf(stderr, "%s: unknown Windows timezone id%s%s\n", | |
| 707 | + PLUGIN_ID, (i + 1 < argc) ? ": " : "", | |
| 708 | + (i + 1 < argc) ? argv[i + 1] : ""); | |
| 709 | + return 1; | |
| 710 | + } | |
| 711 | + printf("%s\n", tz_zone_name(z)); | |
| 712 | + return 0; | |
| 713 | + } | |
| 699 | 714 | if (strcmp(argv[i], "--help") == 0) { print_help(); return 0; } |
| 700 | 715 | } |
| 701 | 716 | if (getenv("SX_PLUGIN_META")) return mode_meta(); |
| index 2d507c4..303257e 100644 | ||
| --- a/src/tz.c | ||
| +++ b/src/tz.c | ||
| @@ -81,6 +81,11 @@ static void zones_build(void) | ||
| 81 | 81 | g_nzones = TZ_ZONE_COUNT; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | +const char *tz_zone_name(const tz_zone *z) | |
| 85 | +{ | |
| 86 | + return z ? z->name : NULL; | |
| 87 | +} | |
| 88 | + | |
| 84 | 89 | int tz_count(void) |
| 85 | 90 | { |
| 86 | 91 | zones_build(); |
| @@ -124,6 +129,23 @@ const tz_zone *tz_find(const char *name) | ||
| 124 | 129 | return NULL; |
| 125 | 130 | } |
| 126 | 131 | |
| 132 | +const tz_zone *tz_find_windows(const char *win_id) | |
| 133 | +{ | |
| 134 | + int i; | |
| 135 | + | |
| 136 | + if (!win_id || !*win_id) return NULL; | |
| 137 | + zones_build(); | |
| 138 | + if (!g_zones) return NULL; | |
| 139 | + for (i = 0; i < TZ_WIN_COUNT; i++) { | |
| 140 | + if (strcmp(TZ_WIN_POOL + TZ_WIN_ZONES[i].win, win_id) != 0) continue; | |
| 141 | + { | |
| 142 | + const char *iana = TZ_NAME_POOL + TZ_WIN_ZONES[i].zone; | |
| 143 | + return tz_find(iana); | |
| 144 | + } | |
| 145 | + } | |
| 146 | + return NULL; | |
| 147 | +} | |
| 148 | + | |
| 127 | 149 | /* ------------------------------------------------------------------ */ |
| 128 | 150 | /* Civil date arithmetic (proleptic Gregorian, days since 1970-01-01) */ |
| 129 | 151 | /* ------------------------------------------------------------------ */ |
| @@ -670,12 +692,41 @@ static int name_from_offset(void) | ||
| 670 | 692 | |
| 671 | 693 | #if defined(_WIN32) |
| 672 | 694 | { |
| 673 | - TIME_ZONE_INFORMATION tz; | |
| 674 | - DWORD kind = GetTimeZoneInformation(&tz); | |
| 675 | - long bias = tz.Bias + ((kind == TIME_ZONE_ID_DAYLIGHT) | |
| 676 | - ? tz.DaylightBias : tz.StandardBias); | |
| 695 | + /* GetDynamicTimeZoneInformation, not GetTimeZoneInformation: the | |
| 696 | + * latter's StandardName is LOCALISED ("Neuseeland Normalzeit" on a | |
| 697 | + * German Windows), while TimeZoneKeyName is always the invariant | |
| 698 | + * registry id every CLDR row is keyed on. Falling back to the old call | |
| 699 | + * keeps a pre-Vista build working. */ | |
| 700 | + DYNAMIC_TIME_ZONE_INFORMATION tz; | |
| 701 | + DWORD kind = GetDynamicTimeZoneInformation(&tz); | |
| 702 | + long bias; | |
| 703 | + char id[128]; | |
| 704 | + | |
| 705 | + bias = tz.Bias + ((kind == TIME_ZONE_ID_DAYLIGHT) | |
| 706 | + ? tz.DaylightBias : tz.StandardBias); | |
| 707 | + if (kind == TIME_ZONE_ID_INVALID) { off = 0; dst = 0; } | |
| 677 | 708 | off = (int)(-bias * 60); |
| 678 | 709 | dst = (kind == TIME_ZONE_ID_DAYLIGHT); |
| 710 | + /* The registry name is the authoritative answer: it names a region, | |
| 711 | + * where an offset names a band shared by a dozen of them. CLDR's map | |
| 712 | + * turns it into the same IANA key every other platform reports. | |
| 713 | + * StandardName is the key CLDR carries ("New Zealand Standard Time"), | |
| 714 | + * so it is tried first; DaylightName ("... Daylight Time") is only a | |
| 715 | + * fallback for a map that happens to carry one. */ | |
| 716 | + WideCharToMultiByte(CP_UTF8, 0, tz.TimeZoneKeyName, -1, id, sizeof id, | |
| 717 | + NULL, NULL); | |
| 718 | + if (tz_find_windows(id)) { | |
| 719 | + snprintf(g_local_name, sizeof g_local_name, "%s", | |
| 720 | + tz_zone_name(tz_find_windows(id))); | |
| 721 | + return 1; | |
| 722 | + } | |
| 723 | + WideCharToMultiByte(CP_UTF8, 0, tz.StandardName, -1, id, sizeof id, | |
| 724 | + NULL, NULL); | |
| 725 | + if (tz_find_windows(id)) { | |
| 726 | + snprintf(g_local_name, sizeof g_local_name, "%s", | |
| 727 | + tz_zone_name(tz_find_windows(id))); | |
| 728 | + return 1; | |
| 729 | + } | |
| 679 | 730 | } |
| 680 | 731 | #else |
| 681 | 732 | { |
| index cd2cedd..2aaa895 100644 | ||
| --- a/src/tz.h | ||
| +++ b/src/tz.h | ||
| @@ -37,10 +37,17 @@ typedef struct { | ||
| 37 | 37 | /* The zone record, opaque outside tz.c. */ |
| 38 | 38 | typedef struct tz_zone tz_zone; |
| 39 | 39 | |
| 40 | +/* The zone's IANA key (valid while the table is loaded). */ | |
| 41 | +const char *tz_zone_name(const tz_zone *z); | |
| 42 | + | |
| 40 | 43 | /* Exact IANA key lookup. Case sensitive on every platform on purpose: see the |
| 41 | 44 | * header comment in tools/gen_tzdata.py. Returns NULL for an unknown key. */ |
| 42 | 45 | const tz_zone *tz_find(const char *name); |
| 43 | 46 | |
| 47 | +/* Windows timezone id ("New Zealand Standard Time") -> IANA key, via the | |
| 48 | + * CLDR map embedded in the table. Returns NULL when the id is unknown. */ | |
| 49 | +const tz_zone *tz_find_windows(const char *win_id); | |
| 50 | + | |
| 44 | 51 | /* Number of embedded zones and their keys (sorted), for the picker UI. */ |
| 45 | 52 | int tz_count(void); |
| 46 | 53 | const char *tz_name_at(int index); |
| index 0b7b41a..573861a 100644 | ||
| --- a/src/tzdata.h | ||
| +++ b/src/tzdata.h | ||
| @@ -18,6 +18,8 @@ | ||
| 18 | 18 | #define TZ_ZONE_COUNT 598 |
| 19 | 19 | #define TZ_TRANS_COUNT 10341 |
| 20 | 20 | |
| 21 | +#define TZ_WIN_COUNT 142 | |
| 22 | + | |
| 21 | 23 | typedef struct { |
| 22 | 24 | uint32_t name; /* offset into TZ_NAME_POOL */ |
| 23 | 25 | uint32_t rule; /* offset into TZ_RULE_POOL */ |
| @@ -100,6 +102,28 @@ static const char TZ_RULE_POOL[] = | ||
| 100 | 102 | ".5.0/3\0MSK-3\0<-00>0\0HST10\0MET-1MEST,M3.5.0,M10.5.0/3\0<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45\0ChST-10\0<-0930>9:30\0SST11\0<+11>-11<+12>,M10.1.0,M4.1.0/3\0" |
| 101 | 103 | ; |
| 102 | 104 | |
| 105 | +static const char TZ_WIN_POOL[] = | |
| 106 | + "AUS Central Standard Time\0AUS Eastern Standard Time\0Afghanistan Standard Time\0Alaskan Standard Time\0Alberta Standard Time\0Aleutian Standard Time\0Altai Standard Time\0Arab Standard T" | |
| 107 | + "ime\0Arabian Standard Time\0Arabic Standard Time\0Argentina Standard Time\0Astrakhan Standard Time\0Atlantic Standard Time\0Aus Central W. Standard Time\0Azerbaijan Standard Time\0Azores S" | |
| 108 | + "tandard Time\0Bahia Standard Time\0Bangladesh Standard Time\0Belarus Standard Time\0Bougainville Standard Time\0British Columbia Standard Time\0Canada Central Standard Time\0Cape Verde St" | |
| 109 | + "andard Time\0Caucasus Standard Time\0Cen. Australia Standard Time\0Central America Standard Time\0Central Asia Standard Time\0Central Brazilian Standard Time\0Central Europe Standard Tim" | |
| 110 | + "e\0Central European Standard Time\0Central Pacific Standard Time\0Central Standard Time\0Central Standard Time (Mexico)\0Chatham Islands Standard Time\0China Standard Time\0Cuba Standard " | |
| 111 | + "Time\0Dateline Standard Time\0E. Africa Standard Time\0E. Australia Standard Time\0E. Europe Standard Time\0E. South America Standard Time\0Easter Island Standard Time\0Eastern Standard T" | |
| 112 | + "ime\0Eastern Standard Time (Mexico)\0Egypt Standard Time\0Ekaterinburg Standard Time\0FLE Standard Time\0Fiji Standard Time\0GMT Standard Time\0GTB Standard Time\0Georgian Standard Time\0Gr" | |
| 113 | + "eenland Standard Time\0Greenwich Standard Time\0Haiti Standard Time\0Hawaiian Standard Time\0India Standard Time\0Iran Standard Time\0Israel Standard Time\0Jordan Standard Time\0Kaliningra" | |
| 114 | + "d Standard Time\0Korea Standard Time\0Libya Standard Time\0Line Islands Standard Time\0Lord Howe Standard Time\0Magadan Standard Time\0Magallanes Standard Time\0Manitoba Standard Time\0Mar" | |
| 115 | + "quesas Standard Time\0Mauritius Standard Time\0Middle East Standard Time\0Montevideo Standard Time\0Morocco Standard Time\0Mountain Standard Time\0Mountain Standard Time (Mexico)\0Myanmar" | |
| 116 | + " Standard Time\0N. Central Asia Standard Time\0Namibia Standard Time\0Nepal Standard Time\0New Zealand Standard Time\0Newfoundland Standard Time\0Norfolk Standard Time\0North Asia East St" | |
| 117 | + "andard Time\0North Asia Standard Time\0North Korea Standard Time\0Omsk Standard Time\0Pacific SA Standard Time\0Pacific Standard Time\0Pacific Standard Time (Mexico)\0Pakistan Standard Ti" | |
| 118 | + "me\0Paraguay Standard Time\0Qyzylorda Standard Time\0Romance Standard Time\0Russia Time Zone 10\0Russia Time Zone 11\0Russia Time Zone 3\0Russian Standard Time\0SA Eastern Standard Time\0SA" | |
| 119 | + " Pacific Standard Time\0SA Western Standard Time\0SE Asia Standard Time\0Saint Pierre Standard Time\0Sakhalin Standard Time\0Samoa Standard Time\0Sao Tome Standard Time\0Saratov Standard " | |
| 120 | + "Time\0Singapore Standard Time\0South Africa Standard Time\0South Sudan Standard Time\0Sri Lanka Standard Time\0Sudan Standard Time\0Syria Standard Time\0Taipei Standard Time\0Tasmania Stan" | |
| 121 | + "dard Time\0Tocantins Standard Time\0Tokyo Standard Time\0Tomsk Standard Time\0Tonga Standard Time\0Transbaikal Standard Time\0Turkey Standard Time\0Turks And Caicos Standard Time\0US Easte" | |
| 122 | + "rn Standard Time\0US Mountain Standard Time\0UTC\0UTC+12\0UTC+13\0UTC-02\0UTC-08\0UTC-09\0UTC-11\0Ulaanbaatar Standard Time\0Venezuela Standard Time\0Vladivostok Standard Time\0Volgograd Stand" | |
| 123 | + "ard Time\0W. Australia Standard Time\0W. Central Africa Standard Time\0W. Europe Standard Time\0W. Mongolia Standard Time\0West Asia Standard Time\0West Bank Standard Time\0West Pacific S" | |
| 124 | + "tandard Time\0Yakutsk Standard Time\0Yukon Standard Time\0" | |
| 125 | + ; | |
| 126 | + | |
| 103 | 127 | static const uint32_t TZ_TR_T[TZ_TRANS_COUNT] = { |
| 104 | 128 | 262562400,278283600,294012000,310338000,325461600,341787600,356911200,373237200,388965600, |
| 105 | 129 | 404686800,420415200,436136400,451864800,467586000,483314400,499640400, |
| @@ -2890,6 +2914,157 @@ static const uint8_t TZ_TR_DST[TZ_TRANS_COUNT] = { | ||
| 2890 | 2914 | 0,1,0,1,0, |
| 2891 | 2915 | }; |
| 2892 | 2916 | |
| 2917 | +/* Windows timezone id -> IANA key (CLDR). */ | |
| 2918 | +typedef struct { | |
| 2919 | + uint16_t win; /* offset into TZ_WIN_POOL */ | |
| 2920 | + uint32_t zone; /* offset into TZ_NAME_POOL */ | |
| 2921 | +} tz_win_t; | |
| 2922 | + | |
| 2923 | +static const tz_win_t TZ_WIN_ZONES[TZ_WIN_COUNT] = { | |
| 2924 | + {0, 5921}, | |
| 2925 | + {26, 6127}, | |
| 2926 | + {52, 4798}, | |
| 2927 | + {78, 844}, | |
| 2928 | + {100, 1908}, | |
| 2929 | + {122, 831}, | |
| 2930 | + {145, 4433}, | |
| 2931 | + {165, 5206}, | |
| 2932 | + {184, 4613}, | |
| 2933 | + {206, 4384}, | |
| 2934 | + {227, 1481}, | |
| 2935 | + {251, 6872}, | |
| 2936 | + {275, 2193}, | |
| 2937 | + {298, 5938}, | |
| 2938 | + {327, 4410}, | |
| 2939 | + {352, 5597}, | |
| 2940 | + {373, 1330}, | |
| 2941 | + {393, 4592}, | |
| 2942 | + {418, 7340}, | |
| 2943 | + {440, 8219}, | |
| 2944 | + {467, 3921}, | |
| 2945 | + {498, 3473}, | |
| 2946 | + {527, 5646}, | |
| 2947 | + {552, 5584}, | |
| 2948 | + {575, 5825}, | |
| 2949 | + {604, 2142}, | |
| 2950 | + {634, 4458}, | |
| 2951 | + {661, 1772}, | |
| 2952 | + {693, 6999}, | |
| 2953 | + {722, 7753}, | |
| 2954 | + {753, 8397}, | |
| 2955 | + {783, 1625}, | |
| 2956 | + {805, 2903}, | |
| 2957 | + {836, 8240}, | |
| 2958 | + {866, 5270}, | |
| 2959 | + {886, 2209}, | |
| 2960 | + {905, 6532}, | |
| 2961 | + {928, 655}, | |
| 2962 | + {952, 5844}, | |
| 2963 | + {979, 7031}, | |
| 2964 | + {1003, 3617}, | |
| 2965 | + {1034, 8270}, | |
| 2966 | + {1062, 3044}, | |
| 2967 | + {1084, 1545}, | |
| 2968 | + {1115, 198}, | |
| 2969 | + {1135, 5565}, | |
| 2970 | + {1162, 7196}, | |
| 2971 | + {1180, 8333}, | |
| 2972 | + {1199, 7264}, | |
| 2973 | + {1217, 6982}, | |
| 2974 | + {1235, 5344}, | |
| 2975 | + {1258, 2054}, | |
| 2976 | + {1282, 5733}, | |
| 2977 | + {1306, 3292}, | |
| 2978 | + {1326, 8430}, | |
| 2979 | + {1349, 4483}, | |
| 2980 | + {1369, 5357}, | |
| 2981 | + {1388, 4783}, | |
| 2982 | + {1409, 4297}, | |
| 2983 | + {1430, 7177}, | |
| 2984 | + {1456, 5259}, | |
| 2985 | + {1476, 787}, | |
| 2986 | + {1496, 8479}, | |
| 2987 | + {1523, 6004}, | |
| 2988 | + {1547, 4988}, | |
| 2989 | + {1569, 3396}, | |
| 2990 | + {1594, 3973}, | |
| 2991 | + {1617, 8546}, | |
| 2992 | + {1641, 8007}, | |
| 2993 | + {1665, 4446}, | |
| 2994 | + {1691, 2974}, | |
| 2995 | + {1716, 211}, | |
| 2996 | + {1738, 1860}, | |
| 2997 | + {1761, 2818}, | |
| 2998 | + {1793, 5193}, | |
| 2999 | + {1815, 5070}, | |
| 3000 | + {1845, 815}, | |
| 3001 | + {1867, 4865}, | |
| 3002 | + {1887, 8202}, | |
| 3003 | + {1913, 3709}, | |
| 3004 | + {1940, 8606}, | |
| 3005 | + {1962, 4729}, | |
| 3006 | + {1992, 4906}, | |
| 3007 | + {2017, 5138}, | |
| 3008 | + {2043, 5087}, | |
| 3009 | + {2062, 3578}, | |
| 3010 | + {2087, 2658}, | |
| 3011 | + {2109, 3873}, | |
| 3012 | + {2140, 4824}, | |
| 3013 | + {2163, 1283}, | |
| 3014 | + {2186, 5178}, | |
| 3015 | + {2210, 7408}, | |
| 3016 | + {2232, 5299}, | |
| 3017 | + {2252, 4809}, | |
| 3018 | + {2272, 7476}, | |
| 3019 | + {2291, 7367}, | |
| 3020 | + {2313, 1594}, | |
| 3021 | + {2338, 1452}, | |
| 3022 | + {2363, 2630}, | |
| 3023 | + {2388, 4420}, | |
| 3024 | + {2410, 2923}, | |
| 3025 | + {2437, 5230}, | |
| 3026 | + {2460, 8189}, | |
| 3027 | + {2480, 755}, | |
| 3028 | + {2503, 7524}, | |
| 3029 | + {2525, 5284}, | |
| 3030 | + {2549, 383}, | |
| 3031 | + {2576, 403}, | |
| 3032 | + {2602, 4554}, | |
| 3033 | + {2626, 430}, | |
| 3034 | + {2646, 4578}, | |
| 3035 | + {2666, 5318}, | |
| 3036 | + {2687, 5954}, | |
| 3037 | + {2710, 895}, | |
| 3038 | + {2734, 5408}, | |
| 3039 | + {2754, 5419}, | |
| 3040 | + {2774, 8815}, | |
| 3041 | + {2794, 4497}, | |
| 3042 | + {2820, 7147}, | |
| 3043 | + {2841, 2088}, | |
| 3044 | + {2872, 2442}, | |
| 3045 | + {2897, 3276}, | |
| 3046 | + {2923, 6809}, | |
| 3047 | + {2927, 6665}, | |
| 3048 | + {2934, 6676}, | |
| 3049 | + {2941, 6543}, | |
| 3050 | + {2948, 6603}, | |
| 3051 | + {2955, 6613}, | |
| 3052 | + {2962, 6521}, | |
| 3053 | + {2969, 5449}, | |
| 3054 | + {2995, 1560}, | |
| 3055 | + {3019, 5523}, | |
| 3056 | + {3045, 7736}, | |
| 3057 | + {3069, 6074}, | |
| 3058 | + {3096, 476}, | |
| 3059 | + {3128, 6934}, | |
| 3060 | + {3152, 4719}, | |
| 3061 | + {3178, 5330}, | |
| 3062 | + {3202, 4675}, | |
| 3063 | + {3226, 8717}, | |
| 3064 | + {3253, 5540}, | |
| 3065 | + {3275, 3954}, | |
| 3066 | +}; | |
| 3067 | + | |
| 2893 | 3068 | static const tz_zone_t TZ_ZONES[TZ_ZONE_COUNT] = { |
| 2894 | 3069 | {0, 0, 0, 0, 0, 0, 0, 1}, |
| 2895 | 3070 | {15, 0, 0, 0, 0, 0, 0, 1}, |
| index da4496b..5728eeb 100755 | ||
| --- a/tests/run.sh | ||
| +++ b/tests/run.sh | ||
| @@ -447,6 +447,21 @@ else | ||
| 447 | 447 | fail "src/ui_html.h is stale - run tools/gen_ui.py" |
| 448 | 448 | fi |
| 449 | 449 | |
| 450 | +# ---------------------------------------------------------------- windows ids | |
| 451 | +section "the Windows timezone map (CLDR)" | |
| 452 | +check "--win-tz resolves the New Zealand registry id" 'Pacific/Auckland' "$($BIN --win-tz 'New Zealand Standard Time')" | |
| 453 | +check "--win-tz resolves Eastern Standard Time" 'America/New_York' "$($BIN --win-tz 'Eastern Standard Time')" | |
| 454 | +check "--win-tz resolves Tokyo Standard Time" 'Asia/Tokyo' "$($BIN --win-tz 'Tokyo Standard Time')" | |
| 455 | +check "--win-tz resolves W. Europe Standard Time" 'Europe/Berlin' "$($BIN --win-tz 'W. Europe Standard Time')" | |
| 456 | +check "--win-tz resolves AUS Eastern Standard Time" 'Australia/Sydney' "$($BIN --win-tz 'AUS Eastern Standard Time')" | |
| 457 | +$BIN --win-tz 'Nonsense Standard Time' >/dev/null 2>&1 && fail "an unknown Windows id must exit non-zero" \ | |
| 458 | + || pass "an unknown Windows id exits non-zero" | |
| 459 | +json_ok "--win-tz answers with a key tz_find accepts" \ | |
| 460 | + "$(printf '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_current_time","arguments":{"timezone":"%s"}}}' "$($BIN --win-tz 'New Zealand Standard Time')" | $BIN --mcp | head -1)" \ | |
| 461 | + "d['result']['structuredContent']['utc_offset']=='+13:00'" | |
| 462 | +grep -q 'TZ_WIN_COUNT 1' src/tzdata.h && pass "the generator embedded the Windows map" \ | |
| 463 | + || fail "the Windows map is missing from src/tzdata.h" | |
| 464 | + | |
| 450 | 465 | # ---------------------------------------------------------------- source guards |
| 451 | 466 | section "source guards" |
| 452 | 467 | SRC="src/plugin_time.c src/timeutil.c src/tz.c src/plugintime.h src/tz.h" |
| index 809e191..2cb92ac 100644 | ||
| --- a/tools/gen_tzdata.py | ||
| +++ b/tools/gen_tzdata.py | ||
| @@ -15,7 +15,11 @@ binary rather than read from the host: | ||
| 15 | 15 | that redesigned their rules (Asia/Hebron, America/Santiago) are correct |
| 16 | 16 | without any rule approximation; |
| 17 | 17 | * each zone's POSIX TZ footer string, used only *beyond* the last embedded |
| 18 | - transition, which is exactly what zoneinfo itself does. | |
| 18 | + transition, which is exactly what zoneinfo itself does; | |
| 19 | + * the Windows timezone id -> IANA key map (tools/windows_zones.tsv, derived | |
| 20 | + from the CLDR supplemental data), so a Windows node reports | |
| 21 | + "New Zealand Standard Time" as Pacific/Auckland rather than guessing from | |
| 22 | + an offset. | |
| 19 | 23 | |
| 20 | 24 | Zones with no transitions in the window still get their offset, abbreviation |
| 21 | 25 | and DST flag stored as the zone's base state. |
| @@ -199,6 +203,23 @@ def max_dst_extra(tts): | ||
| 199 | 203 | return max(offs) - min(offs) |
| 200 | 204 | |
| 201 | 205 | |
| 206 | +def load_windows_map(path): | |
| 207 | + """Windows id -> IANA key, from the checked-in CLDR-derived TSV.""" | |
| 208 | + rows = [] | |
| 209 | + try: | |
| 210 | + with open(path, "r", encoding="utf-8") as f: | |
| 211 | + for line in f: | |
| 212 | + line = line.rstrip("\n") | |
| 213 | + if not line or line.startswith("#"): | |
| 214 | + continue | |
| 215 | + parts = line.split("\t") | |
| 216 | + if len(parts) == 2 and parts[0] and parts[1]: | |
| 217 | + rows.append((parts[0], parts[1])) | |
| 218 | + except OSError: | |
| 219 | + return [] | |
| 220 | + return rows | |
| 221 | + | |
| 222 | + | |
| 202 | 223 | def main(): |
| 203 | 224 | ap = argparse.ArgumentParser() |
| 204 | 225 | ap.add_argument("--tzdir", default="/usr/share/zoneinfo") |
| @@ -218,6 +239,7 @@ def main(): | ||
| 218 | 239 | names = Pool("TZ_NAME_POOL") |
| 219 | 240 | abbrs = Pool("TZ_ABBR_POOL") |
| 220 | 241 | rules = Pool("TZ_RULE_POOL") |
| 242 | + win = Pool("TZ_WIN_POOL") | |
| 221 | 243 | |
| 222 | 244 | tr_t, tr_off, tr_abbr, tr_dst = [], [], [], [] |
| 223 | 245 | records = [] |
| @@ -281,6 +303,17 @@ def main(): | ||
| 281 | 303 | w.append("#define TZ_ZONE_COUNT %d" % len(records)) |
| 282 | 304 | w.append("#define TZ_TRANS_COUNT %d" % len(tr_t)) |
| 283 | 305 | w.append("") |
| 306 | + win_rows = [] | |
| 307 | + for win_id, iana in load_windows_map(os.path.join( | |
| 308 | + os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | |
| 309 | + "tools", "windows_zones.tsv")): | |
| 310 | + # Only keep a mapping whose target the table actually holds: a CLDR | |
| 311 | + # row pointing at a zone this tzdata does not carry would otherwise | |
| 312 | + # resolve to a name tz_find() refuses. | |
| 313 | + if iana in zones: | |
| 314 | + win_rows.append((win.add(win_id), names.add(iana))) | |
| 315 | + w.append("#define TZ_WIN_COUNT %d" % len(win_rows)) | |
| 316 | + w.append("") | |
| 284 | 317 | w.append("typedef struct {") |
| 285 | 318 | w.append(" uint32_t name; /* offset into TZ_NAME_POOL */") |
| 286 | 319 | w.append(" uint32_t rule; /* offset into TZ_RULE_POOL */") |
| @@ -295,6 +328,7 @@ def main(): | ||
| 295 | 328 | names.emit(w) |
| 296 | 329 | abbrs.emit(w) |
| 297 | 330 | rules.emit(w) |
| 331 | + win.emit(w) | |
| 298 | 332 | |
| 299 | 333 | def emit_arr(typ, label, values, per_line=16, fmt=lambda v: str(v)): |
| 300 | 334 | w.append("static const %s %s[TZ_TRANS_COUNT] = {" % (typ, label)) |
| @@ -318,6 +352,17 @@ def main(): | ||
| 318 | 352 | emit_arr("uint16_t", "TZ_TR_ABBR", tr_abbr) |
| 319 | 353 | emit_arr("uint8_t", "TZ_TR_DST", tr_dst, per_line=32) |
| 320 | 354 | |
| 355 | + w.append("/* Windows timezone id -> IANA key (CLDR). */") | |
| 356 | + w.append("typedef struct {") | |
| 357 | + w.append(" uint16_t win; /* offset into TZ_WIN_POOL */") | |
| 358 | + w.append(" uint32_t zone; /* offset into TZ_NAME_POOL */") | |
| 359 | + w.append("} tz_win_t;") | |
| 360 | + w.append("") | |
| 361 | + w.append("static const tz_win_t TZ_WIN_ZONES[TZ_WIN_COUNT] = {") | |
| 362 | + for a, b in win_rows: | |
| 363 | + w.append(" {%d, %d}," % (a, b)) | |
| 364 | + w.append("};") | |
| 365 | + w.append("") | |
| 321 | 366 | w.append("static const tz_zone_t TZ_ZONES[TZ_ZONE_COUNT] = {") |
| 322 | 367 | for r in records: |
| 323 | 368 | w.append(' {%d, %d, %d, %d, %d, %d, %d, %d},' |
| @@ -332,8 +377,9 @@ def main(): | ||
| 332 | 377 | f.write("\n".join(w)) |
| 333 | 378 | |
| 334 | 379 | shrunk = max_dst_extra([]) # noqa: F841 - keeps the helper referenced |
| 335 | - print("gen_tzdata: %d zones, %d transitions -> %s (%d bytes)" | |
| 336 | - % (len(records), len(tr_t), out, os.path.getsize(out)), file=sys.stderr) | |
| 380 | + print("gen_tzdata: %d zones, %d transitions, %d windows ids -> %s (%d bytes)" | |
| 381 | + % (len(records), len(tr_t), len(win_rows), out, os.path.getsize(out)), | |
| 382 | + file=sys.stderr) | |
| 337 | 383 | |
| 338 | 384 | |
| 339 | 385 | if __name__ == "__main__": |
| 1 | 1 | new file mode 100644 |
| index 0000000..372a8b9 | ||
| --- /dev/null | ||
| +++ b/tools/windows_zones.tsv | ||
| @@ -0,0 +1,146 @@ | ||
| 1 | +# Windows timezone name -> canonical IANA key. | |
| 2 | +# Derived from the CLDR supplemental data (common/supplemental/windowsZones.xml), | |
| 3 | +# Unicode CLDR, Unicode License v3. One row per Windows id, using the | |
| 4 | +# territory="001" default where one exists. Regenerate only when CLDR moves. | |
| 5 | +AUS Central Standard Time Australia/Darwin | |
| 6 | +AUS Eastern Standard Time Australia/Sydney | |
| 7 | +Afghanistan Standard Time Asia/Kabul | |
| 8 | +Alaskan Standard Time America/Anchorage | |
| 9 | +Alberta Standard Time America/Edmonton | |
| 10 | +Aleutian Standard Time America/Adak | |
| 11 | +Altai Standard Time Asia/Barnaul | |
| 12 | +Arab Standard Time Asia/Riyadh | |
| 13 | +Arabian Standard Time Asia/Dubai | |
| 14 | +Arabic Standard Time Asia/Baghdad | |
| 15 | +Argentina Standard Time America/Buenos_Aires | |
| 16 | +Astrakhan Standard Time Europe/Astrakhan | |
| 17 | +Atlantic Standard Time America/Halifax | |
| 18 | +Aus Central W. Standard Time Australia/Eucla | |
| 19 | +Azerbaijan Standard Time Asia/Baku | |
| 20 | +Azores Standard Time Atlantic/Azores | |
| 21 | +Bahia Standard Time America/Bahia | |
| 22 | +Bangladesh Standard Time Asia/Dhaka | |
| 23 | +Belarus Standard Time Europe/Minsk | |
| 24 | +Bougainville Standard Time Pacific/Bougainville | |
| 25 | +British Columbia Standard Time America/Vancouver | |
| 26 | +Canada Central Standard Time America/Regina | |
| 27 | +Cape Verde Standard Time Atlantic/Cape_Verde | |
| 28 | +Caucasus Standard Time Asia/Yerevan | |
| 29 | +Cen. Australia Standard Time Australia/Adelaide | |
| 30 | +Central America Standard Time America/Guatemala | |
| 31 | +Central Asia Standard Time Asia/Bishkek | |
| 32 | +Central Brazilian Standard Time America/Cuiaba | |
| 33 | +Central Europe Standard Time Europe/Budapest | |
| 34 | +Central European Standard Time Europe/Warsaw | |
| 35 | +Central Pacific Standard Time Pacific/Guadalcanal | |
| 36 | +Central Standard Time America/Chicago | |
| 37 | +Central Standard Time (Mexico) America/Mexico_City | |
| 38 | +Chatham Islands Standard Time Pacific/Chatham | |
| 39 | +China Standard Time Asia/Shanghai | |
| 40 | +Cuba Standard Time America/Havana | |
| 41 | +Dateline Standard Time Etc/GMT+12 | |
| 42 | +E. Africa Standard Time Africa/Nairobi | |
| 43 | +E. Australia Standard Time Australia/Brisbane | |
| 44 | +E. Europe Standard Time Europe/Chisinau | |
| 45 | +E. South America Standard Time America/Sao_Paulo | |
| 46 | +Easter Island Standard Time Pacific/Easter | |
| 47 | +Eastern Standard Time America/New_York | |
| 48 | +Eastern Standard Time (Mexico) America/Cancun | |
| 49 | +Egypt Standard Time Africa/Cairo | |
| 50 | +Ekaterinburg Standard Time Asia/Yekaterinburg | |
| 51 | +FLE Standard Time Europe/Kiev | |
| 52 | +Fiji Standard Time Pacific/Fiji | |
| 53 | +GMT Standard Time Europe/London | |
| 54 | +GTB Standard Time Europe/Bucharest | |
| 55 | +Georgian Standard Time Asia/Tbilisi | |
| 56 | +Greenland Standard Time America/Godthab | |
| 57 | +Greenwich Standard Time Atlantic/Reykjavik | |
| 58 | +Haiti Standard Time America/Port-au-Prince | |
| 59 | +Hawaiian Standard Time Pacific/Honolulu | |
| 60 | +India Standard Time Asia/Calcutta | |
| 61 | +Iran Standard Time Asia/Tehran | |
| 62 | +Israel Standard Time Asia/Jerusalem | |
| 63 | +Jordan Standard Time Asia/Amman | |
| 64 | +Kaliningrad Standard Time Europe/Kaliningrad | |
| 65 | +Korea Standard Time Asia/Seoul | |
| 66 | +Libya Standard Time Africa/Tripoli | |
| 67 | +Line Islands Standard Time Pacific/Kiritimati | |
| 68 | +Lord Howe Standard Time Australia/Lord_Howe | |
| 69 | +Magadan Standard Time Asia/Magadan | |
| 70 | +Magallanes Standard Time America/Punta_Arenas | |
| 71 | +Manitoba Standard Time America/Winnipeg | |
| 72 | +Marquesas Standard Time Pacific/Marquesas | |
| 73 | +Mauritius Standard Time Indian/Mauritius | |
| 74 | +Middle East Standard Time Asia/Beirut | |
| 75 | +Montevideo Standard Time America/Montevideo | |
| 76 | +Morocco Standard Time Africa/Casablanca | |
| 77 | +Mountain Standard Time America/Denver | |
| 78 | +Mountain Standard Time (Mexico) America/Mazatlan | |
| 79 | +Myanmar Standard Time Asia/Rangoon | |
| 80 | +N. Central Asia Standard Time Asia/Novosibirsk | |
| 81 | +Namibia Standard Time Africa/Windhoek | |
| 82 | +Nepal Standard Time Asia/Katmandu | |
| 83 | +New Zealand Standard Time Pacific/Auckland | |
| 84 | +Newfoundland Standard Time America/St_Johns | |
| 85 | +Norfolk Standard Time Pacific/Norfolk | |
| 86 | +North Asia East Standard Time Asia/Irkutsk | |
| 87 | +North Asia Standard Time Asia/Krasnoyarsk | |
| 88 | +North Korea Standard Time Asia/Pyongyang | |
| 89 | +Omsk Standard Time Asia/Omsk | |
| 90 | +Pacific SA Standard Time America/Santiago | |
| 91 | +Pacific Standard Time America/Los_Angeles | |
| 92 | +Pacific Standard Time (Mexico) America/Tijuana | |
| 93 | +Pakistan Standard Time Asia/Karachi | |
| 94 | +Paraguay Standard Time America/Asuncion | |
| 95 | +Qyzylorda Standard Time Asia/Qyzylorda | |
| 96 | +Romance Standard Time Europe/Paris | |
| 97 | +Russia Time Zone 10 Asia/Srednekolymsk | |
| 98 | +Russia Time Zone 11 Asia/Kamchatka | |
| 99 | +Russia Time Zone 3 Europe/Samara | |
| 100 | +Russian Standard Time Europe/Moscow | |
| 101 | +SA Eastern Standard Time America/Cayenne | |
| 102 | +SA Pacific Standard Time America/Bogota | |
| 103 | +SA Western Standard Time America/La_Paz | |
| 104 | +SE Asia Standard Time Asia/Bangkok | |
| 105 | +Saint Pierre Standard Time America/Miquelon | |
| 106 | +Sakhalin Standard Time Asia/Sakhalin | |
| 107 | +Samoa Standard Time Pacific/Apia | |
| 108 | +Sao Tome Standard Time Africa/Sao_Tome | |
| 109 | +Saratov Standard Time Europe/Saratov | |
| 110 | +Singapore Standard Time Asia/Singapore | |
| 111 | +South Africa Standard Time Africa/Johannesburg | |
| 112 | +South Sudan Standard Time Africa/Juba | |
| 113 | +Sri Lanka Standard Time Asia/Colombo | |
| 114 | +Sudan Standard Time Africa/Khartoum | |
| 115 | +Syria Standard Time Asia/Damascus | |
| 116 | +Taipei Standard Time Asia/Taipei | |
| 117 | +Tasmania Standard Time Australia/Hobart | |
| 118 | +Tocantins Standard Time America/Araguaina | |
| 119 | +Tokyo Standard Time Asia/Tokyo | |
| 120 | +Tomsk Standard Time Asia/Tomsk | |
| 121 | +Tonga Standard Time Pacific/Tongatapu | |
| 122 | +Transbaikal Standard Time Asia/Chita | |
| 123 | +Turkey Standard Time Europe/Istanbul | |
| 124 | +Turks And Caicos Standard Time America/Grand_Turk | |
| 125 | +US Eastern Standard Time America/Indianapolis | |
| 126 | +US Mountain Standard Time America/Phoenix | |
| 127 | +UTC Etc/UTC | |
| 128 | +UTC+12 Etc/GMT-12 | |
| 129 | +UTC+13 Etc/GMT-13 | |
| 130 | +UTC-02 Etc/GMT+2 | |
| 131 | +UTC-08 Etc/GMT+8 | |
| 132 | +UTC-09 Etc/GMT+9 | |
| 133 | +UTC-11 Etc/GMT+11 | |
| 134 | +Ulaanbaatar Standard Time Asia/Ulaanbaatar | |
| 135 | +Venezuela Standard Time America/Caracas | |
| 136 | +Vladivostok Standard Time Asia/Vladivostok | |
| 137 | +Volgograd Standard Time Europe/Volgograd | |
| 138 | +W. Australia Standard Time Australia/Perth | |
| 139 | +W. Central Africa Standard Time Africa/Lagos | |
| 140 | +W. Europe Standard Time Europe/Berlin | |
| 141 | +W. Mongolia Standard Time Asia/Hovd | |
| 142 | +West Asia Standard Time Asia/Tashkent | |
| 143 | +West Bank Standard Time Asia/Hebron | |
| 144 | +West Pacific Standard Time Pacific/Port_Moresby | |
| 145 | +Yakutsk Standard Time Asia/Yakutsk | |
| 146 | +Yukon Standard Time America/Whitehorse | |
| 0 | 147 |
| index 717bebd..bc267cf 100644 | index 717bebd..bc267cf 100644 | ||
| --- a/README.md | --- a/README.md | ||
| +++ b/README.md | +++ b/README.md | ||
| @@ -16,7 +16,7 @@ make win64 # MinGW-w64 static PE -> ./plugin_time.exe | @@ -16,7 +16,7 @@ make win64 # MinGW-w64 static PE -> ./plugin_time.exe | ||
| 16 | make macos # Apple clang (on macOS) -> ./plugin_time | 16 | make macos # Apple clang (on macOS) -> ./plugin_time |
| 17 | make tzdata # regenerate src/tzdata.h from the host tz database | 17 | make tzdata # regenerate src/tzdata.h from the host tz database |
| 18 | make ui # regenerate src/ui_html.h from src/ui.html | 18 | make ui # regenerate src/ui_html.h from src/ui.html |
| 19 | -make test # offline suite (190+ assertions) | 19 | +make test # offline suite (200+ assertions) |
| 20 | python3 tests/e2e.py # Playwright viewport suite (1440 / 1024 / 390, dark + light) | 20 | python3 tests/e2e.py # Playwright viewport suite (1440 / 1024 / 390, dark + light) |
| 21 | ``` | 21 | ``` |
| 22 | 22 | ||
| @@ -37,7 +37,16 @@ about. | @@ -37,7 +37,16 @@ about. | ||
| 37 | (`Africa/Casablanca`) and redesigned rules (`Asia/Hebron`) are exact rather | 37 | (`Africa/Casablanca`) and redesigned rules (`Asia/Hebron`) are exact rather |
| 38 | than approximated; | 38 | than approximated; |
| 39 | * each zone's own POSIX TZ footer string, used only **beyond** the last embedded | 39 | * each zone's own POSIX TZ footer string, used only **beyond** the last embedded |
| 40 | - transition, which is exactly what a host does when it runs out of table. | 40 | + transition, which is exactly what a host does when it runs out of table; |
| 41 | +* the **142** Windows timezone ids from CLDR (`windowsZones.xml`), so a Windows | ||
| 42 | + node reports `New Zealand Standard Time` as `Pacific/Auckland` instead of | ||
| 43 | + guessing from an offset — `plugin_time --win-tz "New Zealand Standard Time"` | ||
| 44 | + answers for a Windows box from any platform. | ||
| 45 | + | ||
| 46 | +The Windows name comes from `GetDynamicTimeZoneInformation().TimeZoneKeyName`, | ||
| 47 | +which is the invariant registry id. `GetTimeZoneInformation().StandardName` is | ||
| 48 | +localised (`Neuseeland Normalzeit` on a German Windows) and matches no CLDR row, | ||
| 49 | +so it is only a fallback. | ||
| 41 | 50 | ||
| 42 | Regeneration is deterministic: the same tz database produces the same bytes, and | 51 | Regeneration is deterministic: the same tz database produces the same bytes, and |
| 43 | `tests/run.sh` re-runs the generator and compares. | 52 | `tests/run.sh` re-runs the generator and compares. |
| @@ -64,7 +73,7 @@ BotCloud container: `/workspace/.scorpiox/plugins/plugin_time`. | @@ -64,7 +73,7 @@ BotCloud container: `/workspace/.scorpiox/plugins/plugin_time`. | ||
| 64 | | **MCP tool provider** | `--mcp` | newline-delimited **JSON-RPC 2.0 over stdio** — `initialize`, `tools/list`, `tools/call`, `ping` | | 73 | | **MCP tool provider** | `--mcp` | newline-delimited **JSON-RPC 2.0 over stdio** — `initialize`, `tools/list`, `tools/call`, `ping` | |
| 65 | | API | `?action=...`, `?format=json`, or any `POST` | `application/json; charset=utf-8` | | 74 | | API | `?action=...`, `?format=json`, or any `POST` | `application/json; charset=utf-8` | |
| 66 | | UI | plain `GET` (`?embed=1` aware) | the World Clock page, `text/html` | | 75 | | UI | plain `GET` (`?embed=1` aware) | the World Clock page, `text/html` | |
| 67 | -| Info | `--version`, `--help`, `--schema` | id + version, usage, the tool schemas | | 76 | +| Info | `--version`, `--help`, `--schema`, `--win-tz <id>` | id + version, usage, the tool schemas, a Windows id -> IANA key | |
| 68 | 77 | ||
| 69 | Modes 3 and 4 sit behind `require_node_auth()`: `X-Bot-Password`, | 78 | Modes 3 and 4 sit behind `require_node_auth()`: `X-Bot-Password`, |
| 70 | `Authorization: Bearer <pwd>`, or `?pwd=`. With `BOT_PASSWORD` unset the check is | 79 | `Authorization: Bearer <pwd>`, or `?pwd=`. With `BOT_PASSWORD` unset the check is |
| index b66deb1..8f500b4 100644 | index b66deb1..8f500b4 100644 | ||
| --- a/docs/usage.md | --- a/docs/usage.md | ||
| +++ b/docs/usage.md | +++ b/docs/usage.md | ||
| @@ -93,7 +93,22 @@ directly. The clock, the converter and the world-clock table all call the tools | @@ -93,7 +93,22 @@ directly. The clock, the converter and the world-clock table all call the tools | ||
| 93 | every second, so what you see is what an agent gets. Add zones with the picker; | 93 | every second, so what you see is what an agent gets. Add zones with the picker; |
| 94 | the list is remembered in your browser. | 94 | the list is remembered in your browser. |
| 95 | 95 | ||
| 96 | -## 8. Updating the database | 96 | +## 8. Windows nodes |
| 97 | + | ||
| 98 | +A Windows box has no tzdata. Its own zone name comes from the registry and is | ||
| 99 | +mapped through CLDR to the same IANA key every other platform reports, so | ||
| 100 | +`get_current_time` with no arguments answers `Pacific/Auckland` there too - not | ||
| 101 | +"UTC+12" and not a guess. | ||
| 102 | + | ||
| 103 | +The whole map is embedded on every platform, so you can check a mapping without a | ||
| 104 | +Windows machine: | ||
| 105 | + | ||
| 106 | +```sh | ||
| 107 | +plugin_time --win-tz "New Zealand Standard Time" # Pacific/Auckland | ||
| 108 | +plugin_time --win-tz "Eastern Standard Time" # America/New_York | ||
| 109 | +``` | ||
| 110 | + | ||
| 111 | +## 9. Updating the database | ||
| 97 | 112 | ||
| 98 | ```sh | 113 | ```sh |
| 99 | make tzdata # regenerate src/tzdata.h from /usr/share/zoneinfo | 114 | make tzdata # regenerate src/tzdata.h from /usr/share/zoneinfo |
| index 9442641..57d977e 100644 | index 9442641..57d977e 100644 | ||
| --- a/src/plugin_time.c | --- a/src/plugin_time.c | ||
| +++ b/src/plugin_time.c | +++ b/src/plugin_time.c | ||
| @@ -670,6 +670,7 @@ static void print_help(void) | @@ -670,6 +670,7 @@ static void print_help(void) | ||
| 670 | " --meta print plugin discovery metadata and exit\n" | 670 | " --meta print plugin discovery metadata and exit\n" |
| 671 | " --mcp serve MCP JSON-RPC 2.0 over stdin/stdout\n" | 671 | " --mcp serve MCP JSON-RPC 2.0 over stdin/stdout\n" |
| 672 | " --schema print the tools/list array\n" | 672 | " --schema print the tools/list array\n" |
| 673 | + " --win-tz <id> resolve a Windows timezone id to its IANA key\n" | ||
| 673 | " --version print version\n" | 674 | " --version print version\n" |
| 674 | " (no args) CGI: World Clock page + ?action= API\n\n" | 675 | " (no args) CGI: World Clock page + ?action= API\n\n" |
| 675 | "tools: ", PLUGIN_ID, PLUGIN_VER); | 676 | "tools: ", PLUGIN_ID, PLUGIN_VER); |
| @@ -696,6 +697,20 @@ int main(int argc, char **argv) | @@ -696,6 +697,20 @@ int main(int argc, char **argv) | ||
| 696 | free(t); | 697 | free(t); |
| 697 | return 0; | 698 | return 0; |
| 698 | } | 699 | } |
| 700 | + if (strcmp(argv[i], "--win-tz") == 0) { | ||
| 701 | + /* Diagnostic: what does a Windows node's registry name resolve to? | ||
| 702 | + * The mapping is embedded on every platform, so this answers for a | ||
| 703 | + * Windows box from a Linux one. */ | ||
| 704 | + const tz_zone *z = (i + 1 < argc) ? tz_find_windows(argv[i + 1]) : NULL; | ||
| 705 | + if (!z) { | ||
| 706 | + fprintf(stderr, "%s: unknown Windows timezone id%s%s\n", | ||
| 707 | + PLUGIN_ID, (i + 1 < argc) ? ": " : "", | ||
| 708 | + (i + 1 < argc) ? argv[i + 1] : ""); | ||
| 709 | + return 1; | ||
| 710 | + } | ||
| 711 | + printf("%s\n", tz_zone_name(z)); | ||
| 712 | + return 0; | ||
| 713 | + } | ||
| 699 | if (strcmp(argv[i], "--help") == 0) { print_help(); return 0; } | 714 | if (strcmp(argv[i], "--help") == 0) { print_help(); return 0; } |
| 700 | } | 715 | } |
| 701 | if (getenv("SX_PLUGIN_META")) return mode_meta(); | 716 | if (getenv("SX_PLUGIN_META")) return mode_meta(); |
| index 2d507c4..303257e 100644 | index 2d507c4..303257e 100644 | ||
| --- a/src/tz.c | --- a/src/tz.c | ||
| +++ b/src/tz.c | +++ b/src/tz.c | ||
| @@ -81,6 +81,11 @@ static void zones_build(void) | @@ -81,6 +81,11 @@ static void zones_build(void) | ||
| 81 | g_nzones = TZ_ZONE_COUNT; | 81 | g_nzones = TZ_ZONE_COUNT; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | +const char *tz_zone_name(const tz_zone *z) | ||
| 85 | +{ | ||
| 86 | + return z ? z->name : NULL; | ||
| 87 | +} | ||
| 88 | + | ||
| 84 | int tz_count(void) | 89 | int tz_count(void) |
| 85 | { | 90 | { |
| 86 | zones_build(); | 91 | zones_build(); |
| @@ -124,6 +129,23 @@ const tz_zone *tz_find(const char *name) | @@ -124,6 +129,23 @@ const tz_zone *tz_find(const char *name) | ||
| 124 | return NULL; | 129 | return NULL; |
| 125 | } | 130 | } |
| 126 | 131 | ||
| 132 | +const tz_zone *tz_find_windows(const char *win_id) | ||
| 133 | +{ | ||
| 134 | + int i; | ||
| 135 | + | ||
| 136 | + if (!win_id || !*win_id) return NULL; | ||
| 137 | + zones_build(); | ||
| 138 | + if (!g_zones) return NULL; | ||
| 139 | + for (i = 0; i < TZ_WIN_COUNT; i++) { | ||
| 140 | + if (strcmp(TZ_WIN_POOL + TZ_WIN_ZONES[i].win, win_id) != 0) continue; | ||
| 141 | + { | ||
| 142 | + const char *iana = TZ_NAME_POOL + TZ_WIN_ZONES[i].zone; | ||
| 143 | + return tz_find(iana); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + return NULL; | ||
| 147 | +} | ||
| 148 | + | ||
| 127 | /* ------------------------------------------------------------------ */ | 149 | /* ------------------------------------------------------------------ */ |
| 128 | /* Civil date arithmetic (proleptic Gregorian, days since 1970-01-01) */ | 150 | /* Civil date arithmetic (proleptic Gregorian, days since 1970-01-01) */ |
| 129 | /* ------------------------------------------------------------------ */ | 151 | /* ------------------------------------------------------------------ */ |
| @@ -670,12 +692,41 @@ static int name_from_offset(void) | @@ -670,12 +692,41 @@ static int name_from_offset(void) | ||
| 670 | 692 | ||
| 671 | #if defined(_WIN32) | 693 | #if defined(_WIN32) |
| 672 | { | 694 | { |
| 673 | - TIME_ZONE_INFORMATION tz; | 695 | + /* GetDynamicTimeZoneInformation, not GetTimeZoneInformation: the |
| 674 | - DWORD kind = GetTimeZoneInformation(&tz); | 696 | + * latter's StandardName is LOCALISED ("Neuseeland Normalzeit" on a |
| 675 | - long bias = tz.Bias + ((kind == TIME_ZONE_ID_DAYLIGHT) | 697 | + * German Windows), while TimeZoneKeyName is always the invariant |
| 676 | - ? tz.DaylightBias : tz.StandardBias); | 698 | + * registry id every CLDR row is keyed on. Falling back to the old call |
| 699 | + * keeps a pre-Vista build working. */ | ||
| 700 | + DYNAMIC_TIME_ZONE_INFORMATION tz; | ||
| 701 | + DWORD kind = GetDynamicTimeZoneInformation(&tz); | ||
| 702 | + long bias; | ||
| 703 | + char id[128]; | ||
| 704 | + | ||
| 705 | + bias = tz.Bias + ((kind == TIME_ZONE_ID_DAYLIGHT) | ||
| 706 | + ? tz.DaylightBias : tz.StandardBias); | ||
| 707 | + if (kind == TIME_ZONE_ID_INVALID) { off = 0; dst = 0; } | ||
| 677 | off = (int)(-bias * 60); | 708 | off = (int)(-bias * 60); |
| 678 | dst = (kind == TIME_ZONE_ID_DAYLIGHT); | 709 | dst = (kind == TIME_ZONE_ID_DAYLIGHT); |
| 710 | + /* The registry name is the authoritative answer: it names a region, | ||
| 711 | + * where an offset names a band shared by a dozen of them. CLDR's map | ||
| 712 | + * turns it into the same IANA key every other platform reports. | ||
| 713 | + * StandardName is the key CLDR carries ("New Zealand Standard Time"), | ||
| 714 | + * so it is tried first; DaylightName ("... Daylight Time") is only a | ||
| 715 | + * fallback for a map that happens to carry one. */ | ||
| 716 | + WideCharToMultiByte(CP_UTF8, 0, tz.TimeZoneKeyName, -1, id, sizeof id, | ||
| 717 | + NULL, NULL); | ||
| 718 | + if (tz_find_windows(id)) { | ||
| 719 | + snprintf(g_local_name, sizeof g_local_name, "%s", | ||
| 720 | + tz_zone_name(tz_find_windows(id))); | ||
| 721 | + return 1; | ||
| 722 | + } | ||
| 723 | + WideCharToMultiByte(CP_UTF8, 0, tz.StandardName, -1, id, sizeof id, | ||
| 724 | + NULL, NULL); | ||
| 725 | + if (tz_find_windows(id)) { | ||
| 726 | + snprintf(g_local_name, sizeof g_local_name, "%s", | ||
| 727 | + tz_zone_name(tz_find_windows(id))); | ||
| 728 | + return 1; | ||
| 729 | + } | ||
| 679 | } | 730 | } |
| 680 | #else | 731 | #else |
| 681 | { | 732 | { |
| index cd2cedd..2aaa895 100644 | index cd2cedd..2aaa895 100644 | ||
| --- a/src/tz.h | --- a/src/tz.h | ||
| +++ b/src/tz.h | +++ b/src/tz.h | ||
| @@ -37,10 +37,17 @@ typedef struct { | @@ -37,10 +37,17 @@ typedef struct { | ||
| 37 | /* The zone record, opaque outside tz.c. */ | 37 | /* The zone record, opaque outside tz.c. */ |
| 38 | typedef struct tz_zone tz_zone; | 38 | typedef struct tz_zone tz_zone; |
| 39 | 39 | ||
| 40 | +/* The zone's IANA key (valid while the table is loaded). */ | ||
| 41 | +const char *tz_zone_name(const tz_zone *z); | ||
| 42 | + | ||
| 40 | /* Exact IANA key lookup. Case sensitive on every platform on purpose: see the | 43 | /* Exact IANA key lookup. Case sensitive on every platform on purpose: see the |
| 41 | * header comment in tools/gen_tzdata.py. Returns NULL for an unknown key. */ | 44 | * header comment in tools/gen_tzdata.py. Returns NULL for an unknown key. */ |
| 42 | const tz_zone *tz_find(const char *name); | 45 | const tz_zone *tz_find(const char *name); |
| 43 | 46 | ||
| 47 | +/* Windows timezone id ("New Zealand Standard Time") -> IANA key, via the | ||
| 48 | + * CLDR map embedded in the table. Returns NULL when the id is unknown. */ | ||
| 49 | +const tz_zone *tz_find_windows(const char *win_id); | ||
| 50 | + | ||
| 44 | /* Number of embedded zones and their keys (sorted), for the picker UI. */ | 51 | /* Number of embedded zones and their keys (sorted), for the picker UI. */ |
| 45 | int tz_count(void); | 52 | int tz_count(void); |
| 46 | const char *tz_name_at(int index); | 53 | const char *tz_name_at(int index); |
| index 0b7b41a..573861a 100644 | index 0b7b41a..573861a 100644 | ||
| --- a/src/tzdata.h | --- a/src/tzdata.h | ||
| +++ b/src/tzdata.h | +++ b/src/tzdata.h | ||
| @@ -18,6 +18,8 @@ | @@ -18,6 +18,8 @@ | ||
| 18 | #define TZ_ZONE_COUNT 598 | 18 | #define TZ_ZONE_COUNT 598 |
| 19 | #define TZ_TRANS_COUNT 10341 | 19 | #define TZ_TRANS_COUNT 10341 |
| 20 | 20 | ||
| 21 | +#define TZ_WIN_COUNT 142 | ||
| 22 | + | ||
| 21 | typedef struct { | 23 | typedef struct { |
| 22 | uint32_t name; /* offset into TZ_NAME_POOL */ | 24 | uint32_t name; /* offset into TZ_NAME_POOL */ |
| 23 | uint32_t rule; /* offset into TZ_RULE_POOL */ | 25 | uint32_t rule; /* offset into TZ_RULE_POOL */ |
| @@ -100,6 +102,28 @@ static const char TZ_RULE_POOL[] = | @@ -100,6 +102,28 @@ static const char TZ_RULE_POOL[] = | ||
| 100 | ".5.0/3\0MSK-3\0<-00>0\0HST10\0MET-1MEST,M3.5.0,M10.5.0/3\0<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45\0ChST-10\0<-0930>9:30\0SST11\0<+11>-11<+12>,M10.1.0,M4.1.0/3\0" | 102 | ".5.0/3\0MSK-3\0<-00>0\0HST10\0MET-1MEST,M3.5.0,M10.5.0/3\0<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45\0ChST-10\0<-0930>9:30\0SST11\0<+11>-11<+12>,M10.1.0,M4.1.0/3\0" |
| 101 | ; | 103 | ; |
| 102 | 104 | ||
| 105 | +static const char TZ_WIN_POOL[] = | ||
| 106 | + "AUS Central Standard Time\0AUS Eastern Standard Time\0Afghanistan Standard Time\0Alaskan Standard Time\0Alberta Standard Time\0Aleutian Standard Time\0Altai Standard Time\0Arab Standard T" | ||
| 107 | + "ime\0Arabian Standard Time\0Arabic Standard Time\0Argentina Standard Time\0Astrakhan Standard Time\0Atlantic Standard Time\0Aus Central W. Standard Time\0Azerbaijan Standard Time\0Azores S" | ||
| 108 | + "tandard Time\0Bahia Standard Time\0Bangladesh Standard Time\0Belarus Standard Time\0Bougainville Standard Time\0British Columbia Standard Time\0Canada Central Standard Time\0Cape Verde St" | ||
| 109 | + "andard Time\0Caucasus Standard Time\0Cen. Australia Standard Time\0Central America Standard Time\0Central Asia Standard Time\0Central Brazilian Standard Time\0Central Europe Standard Tim" | ||
| 110 | + "e\0Central European Standard Time\0Central Pacific Standard Time\0Central Standard Time\0Central Standard Time (Mexico)\0Chatham Islands Standard Time\0China Standard Time\0Cuba Standard " | ||
| 111 | + "Time\0Dateline Standard Time\0E. Africa Standard Time\0E. Australia Standard Time\0E. Europe Standard Time\0E. South America Standard Time\0Easter Island Standard Time\0Eastern Standard T" | ||
| 112 | + "ime\0Eastern Standard Time (Mexico)\0Egypt Standard Time\0Ekaterinburg Standard Time\0FLE Standard Time\0Fiji Standard Time\0GMT Standard Time\0GTB Standard Time\0Georgian Standard Time\0Gr" | ||
| 113 | + "eenland Standard Time\0Greenwich Standard Time\0Haiti Standard Time\0Hawaiian Standard Time\0India Standard Time\0Iran Standard Time\0Israel Standard Time\0Jordan Standard Time\0Kaliningra" | ||
| 114 | + "d Standard Time\0Korea Standard Time\0Libya Standard Time\0Line Islands Standard Time\0Lord Howe Standard Time\0Magadan Standard Time\0Magallanes Standard Time\0Manitoba Standard Time\0Mar" | ||
| 115 | + "quesas Standard Time\0Mauritius Standard Time\0Middle East Standard Time\0Montevideo Standard Time\0Morocco Standard Time\0Mountain Standard Time\0Mountain Standard Time (Mexico)\0Myanmar" | ||
| 116 | + " Standard Time\0N. Central Asia Standard Time\0Namibia Standard Time\0Nepal Standard Time\0New Zealand Standard Time\0Newfoundland Standard Time\0Norfolk Standard Time\0North Asia East St" | ||
| 117 | + "andard Time\0North Asia Standard Time\0North Korea Standard Time\0Omsk Standard Time\0Pacific SA Standard Time\0Pacific Standard Time\0Pacific Standard Time (Mexico)\0Pakistan Standard Ti" | ||
| 118 | + "me\0Paraguay Standard Time\0Qyzylorda Standard Time\0Romance Standard Time\0Russia Time Zone 10\0Russia Time Zone 11\0Russia Time Zone 3\0Russian Standard Time\0SA Eastern Standard Time\0SA" | ||
| 119 | + " Pacific Standard Time\0SA Western Standard Time\0SE Asia Standard Time\0Saint Pierre Standard Time\0Sakhalin Standard Time\0Samoa Standard Time\0Sao Tome Standard Time\0Saratov Standard " | ||
| 120 | + "Time\0Singapore Standard Time\0South Africa Standard Time\0South Sudan Standard Time\0Sri Lanka Standard Time\0Sudan Standard Time\0Syria Standard Time\0Taipei Standard Time\0Tasmania Stan" | ||
| 121 | + "dard Time\0Tocantins Standard Time\0Tokyo Standard Time\0Tomsk Standard Time\0Tonga Standard Time\0Transbaikal Standard Time\0Turkey Standard Time\0Turks And Caicos Standard Time\0US Easte" | ||
| 122 | + "rn Standard Time\0US Mountain Standard Time\0UTC\0UTC+12\0UTC+13\0UTC-02\0UTC-08\0UTC-09\0UTC-11\0Ulaanbaatar Standard Time\0Venezuela Standard Time\0Vladivostok Standard Time\0Volgograd Stand" | ||
| 123 | + "ard Time\0W. Australia Standard Time\0W. Central Africa Standard Time\0W. Europe Standard Time\0W. Mongolia Standard Time\0West Asia Standard Time\0West Bank Standard Time\0West Pacific S" | ||
| 124 | + "tandard Time\0Yakutsk Standard Time\0Yukon Standard Time\0" | ||
| 125 | + ; | ||
| 126 | + | ||
| 103 | static const uint32_t TZ_TR_T[TZ_TRANS_COUNT] = { | 127 | static const uint32_t TZ_TR_T[TZ_TRANS_COUNT] = { |
| 104 | 262562400,278283600,294012000,310338000,325461600,341787600,356911200,373237200,388965600, | 128 | 262562400,278283600,294012000,310338000,325461600,341787600,356911200,373237200,388965600, |
| 105 | 404686800,420415200,436136400,451864800,467586000,483314400,499640400, | 129 | 404686800,420415200,436136400,451864800,467586000,483314400,499640400, |
| @@ -2890,6 +2914,157 @@ static const uint8_t TZ_TR_DST[TZ_TRANS_COUNT] = { | @@ -2890,6 +2914,157 @@ static const uint8_t TZ_TR_DST[TZ_TRANS_COUNT] = { | ||
| 2890 | 0,1,0,1,0, | 2914 | 0,1,0,1,0, |
| 2891 | }; | 2915 | }; |
| 2892 | 2916 | ||
| 2917 | +/* Windows timezone id -> IANA key (CLDR). */ | ||
| 2918 | +typedef struct { | ||
| 2919 | + uint16_t win; /* offset into TZ_WIN_POOL */ | ||
| 2920 | + uint32_t zone; /* offset into TZ_NAME_POOL */ | ||
| 2921 | +} tz_win_t; | ||
| 2922 | + | ||
| 2923 | +static const tz_win_t TZ_WIN_ZONES[TZ_WIN_COUNT] = { | ||
| 2924 | + {0, 5921}, | ||
| 2925 | + {26, 6127}, | ||
| 2926 | + {52, 4798}, | ||
| 2927 | + {78, 844}, | ||
| 2928 | + {100, 1908}, | ||
| 2929 | + {122, 831}, | ||
| 2930 | + {145, 4433}, | ||
| 2931 | + {165, 5206}, | ||
| 2932 | + {184, 4613}, | ||
| 2933 | + {206, 4384}, | ||
| 2934 | + {227, 1481}, | ||
| 2935 | + {251, 6872}, | ||
| 2936 | + {275, 2193}, | ||
| 2937 | + {298, 5938}, | ||
| 2938 | + {327, 4410}, | ||
| 2939 | + {352, 5597}, | ||
| 2940 | + {373, 1330}, | ||
| 2941 | + {393, 4592}, | ||
| 2942 | + {418, 7340}, | ||
| 2943 | + {440, 8219}, | ||
| 2944 | + {467, 3921}, | ||
| 2945 | + {498, 3473}, | ||
| 2946 | + {527, 5646}, | ||
| 2947 | + {552, 5584}, | ||
| 2948 | + {575, 5825}, | ||
| 2949 | + {604, 2142}, | ||
| 2950 | + {634, 4458}, | ||
| 2951 | + {661, 1772}, | ||
| 2952 | + {693, 6999}, | ||
| 2953 | + {722, 7753}, | ||
| 2954 | + {753, 8397}, | ||
| 2955 | + {783, 1625}, | ||
| 2956 | + {805, 2903}, | ||
| 2957 | + {836, 8240}, | ||
| 2958 | + {866, 5270}, | ||
| 2959 | + {886, 2209}, | ||
| 2960 | + {905, 6532}, | ||
| 2961 | + {928, 655}, | ||
| 2962 | + {952, 5844}, | ||
| 2963 | + {979, 7031}, | ||
| 2964 | + {1003, 3617}, | ||
| 2965 | + {1034, 8270}, | ||
| 2966 | + {1062, 3044}, | ||
| 2967 | + {1084, 1545}, | ||
| 2968 | + {1115, 198}, | ||
| 2969 | + {1135, 5565}, | ||
| 2970 | + {1162, 7196}, | ||
| 2971 | + {1180, 8333}, | ||
| 2972 | + {1199, 7264}, | ||
| 2973 | + {1217, 6982}, | ||
| 2974 | + {1235, 5344}, | ||
| 2975 | + {1258, 2054}, | ||
| 2976 | + {1282, 5733}, | ||
| 2977 | + {1306, 3292}, | ||
| 2978 | + {1326, 8430}, | ||
| 2979 | + {1349, 4483}, | ||
| 2980 | + {1369, 5357}, | ||
| 2981 | + {1388, 4783}, | ||
| 2982 | + {1409, 4297}, | ||
| 2983 | + {1430, 7177}, | ||
| 2984 | + {1456, 5259}, | ||
| 2985 | + {1476, 787}, | ||
| 2986 | + {1496, 8479}, | ||
| 2987 | + {1523, 6004}, | ||
| 2988 | + {1547, 4988}, | ||
| 2989 | + {1569, 3396}, | ||
| 2990 | + {1594, 3973}, | ||
| 2991 | + {1617, 8546}, | ||
| 2992 | + {1641, 8007}, | ||
| 2993 | + {1665, 4446}, | ||
| 2994 | + {1691, 2974}, | ||
| 2995 | + {1716, 211}, | ||
| 2996 | + {1738, 1860}, | ||
| 2997 | + {1761, 2818}, | ||
| 2998 | + {1793, 5193}, | ||
| 2999 | + {1815, 5070}, | ||
| 3000 | + {1845, 815}, | ||
| 3001 | + {1867, 4865}, | ||
| 3002 | + {1887, 8202}, | ||
| 3003 | + {1913, 3709}, | ||
| 3004 | + {1940, 8606}, | ||
| 3005 | + {1962, 4729}, | ||
| 3006 | + {1992, 4906}, | ||
| 3007 | + {2017, 5138}, | ||
| 3008 | + {2043, 5087}, | ||
| 3009 | + {2062, 3578}, | ||
| 3010 | + {2087, 2658}, | ||
| 3011 | + {2109, 3873}, | ||
| 3012 | + {2140, 4824}, | ||
| 3013 | + {2163, 1283}, | ||
| 3014 | + {2186, 5178}, | ||
| 3015 | + {2210, 7408}, | ||
| 3016 | + {2232, 5299}, | ||
| 3017 | + {2252, 4809}, | ||
| 3018 | + {2272, 7476}, | ||
| 3019 | + {2291, 7367}, | ||
| 3020 | + {2313, 1594}, | ||
| 3021 | + {2338, 1452}, | ||
| 3022 | + {2363, 2630}, | ||
| 3023 | + {2388, 4420}, | ||
| 3024 | + {2410, 2923}, | ||
| 3025 | + {2437, 5230}, | ||
| 3026 | + {2460, 8189}, | ||
| 3027 | + {2480, 755}, | ||
| 3028 | + {2503, 7524}, | ||
| 3029 | + {2525, 5284}, | ||
| 3030 | + {2549, 383}, | ||
| 3031 | + {2576, 403}, | ||
| 3032 | + {2602, 4554}, | ||
| 3033 | + {2626, 430}, | ||
| 3034 | + {2646, 4578}, | ||
| 3035 | + {2666, 5318}, | ||
| 3036 | + {2687, 5954}, | ||
| 3037 | + {2710, 895}, | ||
| 3038 | + {2734, 5408}, | ||
| 3039 | + {2754, 5419}, | ||
| 3040 | + {2774, 8815}, | ||
| 3041 | + {2794, 4497}, | ||
| 3042 | + {2820, 7147}, | ||
| 3043 | + {2841, 2088}, | ||
| 3044 | + {2872, 2442}, | ||
| 3045 | + {2897, 3276}, | ||
| 3046 | + {2923, 6809}, | ||
| 3047 | + {2927, 6665}, | ||
| 3048 | + {2934, 6676}, | ||
| 3049 | + {2941, 6543}, | ||
| 3050 | + {2948, 6603}, | ||
| 3051 | + {2955, 6613}, | ||
| 3052 | + {2962, 6521}, | ||
| 3053 | + {2969, 5449}, | ||
| 3054 | + {2995, 1560}, | ||
| 3055 | + {3019, 5523}, | ||
| 3056 | + {3045, 7736}, | ||
| 3057 | + {3069, 6074}, | ||
| 3058 | + {3096, 476}, | ||
| 3059 | + {3128, 6934}, | ||
| 3060 | + {3152, 4719}, | ||
| 3061 | + {3178, 5330}, | ||
| 3062 | + {3202, 4675}, | ||
| 3063 | + {3226, 8717}, | ||
| 3064 | + {3253, 5540}, | ||
| 3065 | + {3275, 3954}, | ||
| 3066 | +}; | ||
| 3067 | + | ||
| 2893 | static const tz_zone_t TZ_ZONES[TZ_ZONE_COUNT] = { | 3068 | static const tz_zone_t TZ_ZONES[TZ_ZONE_COUNT] = { |
| 2894 | {0, 0, 0, 0, 0, 0, 0, 1}, | 3069 | {0, 0, 0, 0, 0, 0, 0, 1}, |
| 2895 | {15, 0, 0, 0, 0, 0, 0, 1}, | 3070 | {15, 0, 0, 0, 0, 0, 0, 1}, |
| index da4496b..5728eeb 100755 | index da4496b..5728eeb 100755 | ||
| --- a/tests/run.sh | --- a/tests/run.sh | ||
| +++ b/tests/run.sh | +++ b/tests/run.sh | ||
| @@ -447,6 +447,21 @@ else | @@ -447,6 +447,21 @@ else | ||
| 447 | fail "src/ui_html.h is stale - run tools/gen_ui.py" | 447 | fail "src/ui_html.h is stale - run tools/gen_ui.py" |
| 448 | fi | 448 | fi |
| 449 | 449 | ||
| 450 | +# ---------------------------------------------------------------- windows ids | ||
| 451 | +section "the Windows timezone map (CLDR)" | ||
| 452 | +check "--win-tz resolves the New Zealand registry id" 'Pacific/Auckland' "$($BIN --win-tz 'New Zealand Standard Time')" | ||
| 453 | +check "--win-tz resolves Eastern Standard Time" 'America/New_York' "$($BIN --win-tz 'Eastern Standard Time')" | ||
| 454 | +check "--win-tz resolves Tokyo Standard Time" 'Asia/Tokyo' "$($BIN --win-tz 'Tokyo Standard Time')" | ||
| 455 | +check "--win-tz resolves W. Europe Standard Time" 'Europe/Berlin' "$($BIN --win-tz 'W. Europe Standard Time')" | ||
| 456 | +check "--win-tz resolves AUS Eastern Standard Time" 'Australia/Sydney' "$($BIN --win-tz 'AUS Eastern Standard Time')" | ||
| 457 | +$BIN --win-tz 'Nonsense Standard Time' >/dev/null 2>&1 && fail "an unknown Windows id must exit non-zero" \ | ||
| 458 | + || pass "an unknown Windows id exits non-zero" | ||
| 459 | +json_ok "--win-tz answers with a key tz_find accepts" \ | ||
| 460 | + "$(printf '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_current_time","arguments":{"timezone":"%s"}}}' "$($BIN --win-tz 'New Zealand Standard Time')" | $BIN --mcp | head -1)" \ | ||
| 461 | + "d['result']['structuredContent']['utc_offset']=='+13:00'" | ||
| 462 | +grep -q 'TZ_WIN_COUNT 1' src/tzdata.h && pass "the generator embedded the Windows map" \ | ||
| 463 | + || fail "the Windows map is missing from src/tzdata.h" | ||
| 464 | + | ||
| 450 | # ---------------------------------------------------------------- source guards | 465 | # ---------------------------------------------------------------- source guards |
| 451 | section "source guards" | 466 | section "source guards" |
| 452 | SRC="src/plugin_time.c src/timeutil.c src/tz.c src/plugintime.h src/tz.h" | 467 | SRC="src/plugin_time.c src/timeutil.c src/tz.c src/plugintime.h src/tz.h" |
| index 809e191..2cb92ac 100644 | index 809e191..2cb92ac 100644 | ||
| --- a/tools/gen_tzdata.py | --- a/tools/gen_tzdata.py | ||
| +++ b/tools/gen_tzdata.py | +++ b/tools/gen_tzdata.py | ||
| @@ -15,7 +15,11 @@ binary rather than read from the host: | @@ -15,7 +15,11 @@ binary rather than read from the host: | ||
| 15 | that redesigned their rules (Asia/Hebron, America/Santiago) are correct | 15 | that redesigned their rules (Asia/Hebron, America/Santiago) are correct |
| 16 | without any rule approximation; | 16 | without any rule approximation; |
| 17 | * each zone's POSIX TZ footer string, used only *beyond* the last embedded | 17 | * each zone's POSIX TZ footer string, used only *beyond* the last embedded |
| 18 | - transition, which is exactly what zoneinfo itself does. | 18 | + transition, which is exactly what zoneinfo itself does; |
| 19 | + * the Windows timezone id -> IANA key map (tools/windows_zones.tsv, derived | ||
| 20 | + from the CLDR supplemental data), so a Windows node reports | ||
| 21 | + "New Zealand Standard Time" as Pacific/Auckland rather than guessing from | ||
| 22 | + an offset. | ||
| 19 | 23 | ||
| 20 | Zones with no transitions in the window still get their offset, abbreviation | 24 | Zones with no transitions in the window still get their offset, abbreviation |
| 21 | and DST flag stored as the zone's base state. | 25 | and DST flag stored as the zone's base state. |
| @@ -199,6 +203,23 @@ def max_dst_extra(tts): | @@ -199,6 +203,23 @@ def max_dst_extra(tts): | ||
| 199 | return max(offs) - min(offs) | 203 | return max(offs) - min(offs) |
| 200 | 204 | ||
| 201 | 205 | ||
| 206 | +def load_windows_map(path): | ||
| 207 | + """Windows id -> IANA key, from the checked-in CLDR-derived TSV.""" | ||
| 208 | + rows = [] | ||
| 209 | + try: | ||
| 210 | + with open(path, "r", encoding="utf-8") as f: | ||
| 211 | + for line in f: | ||
| 212 | + line = line.rstrip("\n") | ||
| 213 | + if not line or line.startswith("#"): | ||
| 214 | + continue | ||
| 215 | + parts = line.split("\t") | ||
| 216 | + if len(parts) == 2 and parts[0] and parts[1]: | ||
| 217 | + rows.append((parts[0], parts[1])) | ||
| 218 | + except OSError: | ||
| 219 | + return [] | ||
| 220 | + return rows | ||
| 221 | + | ||
| 222 | + | ||
| 202 | def main(): | 223 | def main(): |
| 203 | ap = argparse.ArgumentParser() | 224 | ap = argparse.ArgumentParser() |
| 204 | ap.add_argument("--tzdir", default="/usr/share/zoneinfo") | 225 | ap.add_argument("--tzdir", default="/usr/share/zoneinfo") |
| @@ -218,6 +239,7 @@ def main(): | @@ -218,6 +239,7 @@ def main(): | ||
| 218 | names = Pool("TZ_NAME_POOL") | 239 | names = Pool("TZ_NAME_POOL") |
| 219 | abbrs = Pool("TZ_ABBR_POOL") | 240 | abbrs = Pool("TZ_ABBR_POOL") |
| 220 | rules = Pool("TZ_RULE_POOL") | 241 | rules = Pool("TZ_RULE_POOL") |
| 242 | + win = Pool("TZ_WIN_POOL") | ||
| 221 | 243 | ||
| 222 | tr_t, tr_off, tr_abbr, tr_dst = [], [], [], [] | 244 | tr_t, tr_off, tr_abbr, tr_dst = [], [], [], [] |
| 223 | records = [] | 245 | records = [] |
| @@ -281,6 +303,17 @@ def main(): | @@ -281,6 +303,17 @@ def main(): | ||
| 281 | w.append("#define TZ_ZONE_COUNT %d" % len(records)) | 303 | w.append("#define TZ_ZONE_COUNT %d" % len(records)) |
| 282 | w.append("#define TZ_TRANS_COUNT %d" % len(tr_t)) | 304 | w.append("#define TZ_TRANS_COUNT %d" % len(tr_t)) |
| 283 | w.append("") | 305 | w.append("") |
| 306 | + win_rows = [] | ||
| 307 | + for win_id, iana in load_windows_map(os.path.join( | ||
| 308 | + os.path.dirname(os.path.dirname(os.path.abspath(__file__))), | ||
| 309 | + "tools", "windows_zones.tsv")): | ||
| 310 | + # Only keep a mapping whose target the table actually holds: a CLDR | ||
| 311 | + # row pointing at a zone this tzdata does not carry would otherwise | ||
| 312 | + # resolve to a name tz_find() refuses. | ||
| 313 | + if iana in zones: | ||
| 314 | + win_rows.append((win.add(win_id), names.add(iana))) | ||
| 315 | + w.append("#define TZ_WIN_COUNT %d" % len(win_rows)) | ||
| 316 | + w.append("") | ||
| 284 | w.append("typedef struct {") | 317 | w.append("typedef struct {") |
| 285 | w.append(" uint32_t name; /* offset into TZ_NAME_POOL */") | 318 | w.append(" uint32_t name; /* offset into TZ_NAME_POOL */") |
| 286 | w.append(" uint32_t rule; /* offset into TZ_RULE_POOL */") | 319 | w.append(" uint32_t rule; /* offset into TZ_RULE_POOL */") |
| @@ -295,6 +328,7 @@ def main(): | @@ -295,6 +328,7 @@ def main(): | ||
| 295 | names.emit(w) | 328 | names.emit(w) |
| 296 | abbrs.emit(w) | 329 | abbrs.emit(w) |
| 297 | rules.emit(w) | 330 | rules.emit(w) |
| 331 | + win.emit(w) | ||
| 298 | 332 | ||
| 299 | def emit_arr(typ, label, values, per_line=16, fmt=lambda v: str(v)): | 333 | def emit_arr(typ, label, values, per_line=16, fmt=lambda v: str(v)): |
| 300 | w.append("static const %s %s[TZ_TRANS_COUNT] = {" % (typ, label)) | 334 | w.append("static const %s %s[TZ_TRANS_COUNT] = {" % (typ, label)) |
| @@ -318,6 +352,17 @@ def main(): | @@ -318,6 +352,17 @@ def main(): | ||
| 318 | emit_arr("uint16_t", "TZ_TR_ABBR", tr_abbr) | 352 | emit_arr("uint16_t", "TZ_TR_ABBR", tr_abbr) |
| 319 | emit_arr("uint8_t", "TZ_TR_DST", tr_dst, per_line=32) | 353 | emit_arr("uint8_t", "TZ_TR_DST", tr_dst, per_line=32) |
| 320 | 354 | ||
| 355 | + w.append("/* Windows timezone id -> IANA key (CLDR). */") | ||
| 356 | + w.append("typedef struct {") | ||
| 357 | + w.append(" uint16_t win; /* offset into TZ_WIN_POOL */") | ||
| 358 | + w.append(" uint32_t zone; /* offset into TZ_NAME_POOL */") | ||
| 359 | + w.append("} tz_win_t;") | ||
| 360 | + w.append("") | ||
| 361 | + w.append("static const tz_win_t TZ_WIN_ZONES[TZ_WIN_COUNT] = {") | ||
| 362 | + for a, b in win_rows: | ||
| 363 | + w.append(" {%d, %d}," % (a, b)) | ||
| 364 | + w.append("};") | ||
| 365 | + w.append("") | ||
| 321 | w.append("static const tz_zone_t TZ_ZONES[TZ_ZONE_COUNT] = {") | 366 | w.append("static const tz_zone_t TZ_ZONES[TZ_ZONE_COUNT] = {") |
| 322 | for r in records: | 367 | for r in records: |
| 323 | w.append(' {%d, %d, %d, %d, %d, %d, %d, %d},' | 368 | w.append(' {%d, %d, %d, %d, %d, %d, %d, %d},' |
| @@ -332,8 +377,9 @@ def main(): | @@ -332,8 +377,9 @@ def main(): | ||
| 332 | f.write("\n".join(w)) | 377 | f.write("\n".join(w)) |
| 333 | 378 | ||
| 334 | shrunk = max_dst_extra([]) # noqa: F841 - keeps the helper referenced | 379 | shrunk = max_dst_extra([]) # noqa: F841 - keeps the helper referenced |
| 335 | - print("gen_tzdata: %d zones, %d transitions -> %s (%d bytes)" | 380 | + print("gen_tzdata: %d zones, %d transitions, %d windows ids -> %s (%d bytes)" |
| 336 | - % (len(records), len(tr_t), out, os.path.getsize(out)), file=sys.stderr) | 381 | + % (len(records), len(tr_t), len(win_rows), out, os.path.getsize(out)), |
| 382 | + file=sys.stderr) | ||
| 337 | 383 | ||
| 338 | 384 | ||
| 339 | if __name__ == "__main__": | 385 | if __name__ == "__main__": |
| 1 | new file mode 100644 | 1 | new file mode 100644 |
| index 0000000..372a8b9 | index 0000000..372a8b9 | ||
| --- /dev/null | --- /dev/null | ||
| +++ b/tools/windows_zones.tsv | +++ b/tools/windows_zones.tsv | ||
| @@ -0,0 +1,146 @@ | @@ -0,0 +1,146 @@ | ||
| 1 | +# Windows timezone name -> canonical IANA key. | ||
| 2 | +# Derived from the CLDR supplemental data (common/supplemental/windowsZones.xml), | ||
| 3 | +# Unicode CLDR, Unicode License v3. One row per Windows id, using the | ||
| 4 | +# territory="001" default where one exists. Regenerate only when CLDR moves. | ||
| 5 | +AUS Central Standard Time Australia/Darwin | ||
| 6 | +AUS Eastern Standard Time Australia/Sydney | ||
| 7 | +Afghanistan Standard Time Asia/Kabul | ||
| 8 | +Alaskan Standard Time America/Anchorage | ||
| 9 | +Alberta Standard Time America/Edmonton | ||
| 10 | +Aleutian Standard Time America/Adak | ||
| 11 | +Altai Standard Time Asia/Barnaul | ||
| 12 | +Arab Standard Time Asia/Riyadh | ||
| 13 | +Arabian Standard Time Asia/Dubai | ||
| 14 | +Arabic Standard Time Asia/Baghdad | ||
| 15 | +Argentina Standard Time America/Buenos_Aires | ||
| 16 | +Astrakhan Standard Time Europe/Astrakhan | ||
| 17 | +Atlantic Standard Time America/Halifax | ||
| 18 | +Aus Central W. Standard Time Australia/Eucla | ||
| 19 | +Azerbaijan Standard Time Asia/Baku | ||
| 20 | +Azores Standard Time Atlantic/Azores | ||
| 21 | +Bahia Standard Time America/Bahia | ||
| 22 | +Bangladesh Standard Time Asia/Dhaka | ||
| 23 | +Belarus Standard Time Europe/Minsk | ||
| 24 | +Bougainville Standard Time Pacific/Bougainville | ||
| 25 | +British Columbia Standard Time America/Vancouver | ||
| 26 | +Canada Central Standard Time America/Regina | ||
| 27 | +Cape Verde Standard Time Atlantic/Cape_Verde | ||
| 28 | +Caucasus Standard Time Asia/Yerevan | ||
| 29 | +Cen. Australia Standard Time Australia/Adelaide | ||
| 30 | +Central America Standard Time America/Guatemala | ||
| 31 | +Central Asia Standard Time Asia/Bishkek | ||
| 32 | +Central Brazilian Standard Time America/Cuiaba | ||
| 33 | +Central Europe Standard Time Europe/Budapest | ||
| 34 | +Central European Standard Time Europe/Warsaw | ||
| 35 | +Central Pacific Standard Time Pacific/Guadalcanal | ||
| 36 | +Central Standard Time America/Chicago | ||
| 37 | +Central Standard Time (Mexico) America/Mexico_City | ||
| 38 | +Chatham Islands Standard Time Pacific/Chatham | ||
| 39 | +China Standard Time Asia/Shanghai | ||
| 40 | +Cuba Standard Time America/Havana | ||
| 41 | +Dateline Standard Time Etc/GMT+12 | ||
| 42 | +E. Africa Standard Time Africa/Nairobi | ||
| 43 | +E. Australia Standard Time Australia/Brisbane | ||
| 44 | +E. Europe Standard Time Europe/Chisinau | ||
| 45 | +E. South America Standard Time America/Sao_Paulo | ||
| 46 | +Easter Island Standard Time Pacific/Easter | ||
| 47 | +Eastern Standard Time America/New_York | ||
| 48 | +Eastern Standard Time (Mexico) America/Cancun | ||
| 49 | +Egypt Standard Time Africa/Cairo | ||
| 50 | +Ekaterinburg Standard Time Asia/Yekaterinburg | ||
| 51 | +FLE Standard Time Europe/Kiev | ||
| 52 | +Fiji Standard Time Pacific/Fiji | ||
| 53 | +GMT Standard Time Europe/London | ||
| 54 | +GTB Standard Time Europe/Bucharest | ||
| 55 | +Georgian Standard Time Asia/Tbilisi | ||
| 56 | +Greenland Standard Time America/Godthab | ||
| 57 | +Greenwich Standard Time Atlantic/Reykjavik | ||
| 58 | +Haiti Standard Time America/Port-au-Prince | ||
| 59 | +Hawaiian Standard Time Pacific/Honolulu | ||
| 60 | +India Standard Time Asia/Calcutta | ||
| 61 | +Iran Standard Time Asia/Tehran | ||
| 62 | +Israel Standard Time Asia/Jerusalem | ||
| 63 | +Jordan Standard Time Asia/Amman | ||
| 64 | +Kaliningrad Standard Time Europe/Kaliningrad | ||
| 65 | +Korea Standard Time Asia/Seoul | ||
| 66 | +Libya Standard Time Africa/Tripoli | ||
| 67 | +Line Islands Standard Time Pacific/Kiritimati | ||
| 68 | +Lord Howe Standard Time Australia/Lord_Howe | ||
| 69 | +Magadan Standard Time Asia/Magadan | ||
| 70 | +Magallanes Standard Time America/Punta_Arenas | ||
| 71 | +Manitoba Standard Time America/Winnipeg | ||
| 72 | +Marquesas Standard Time Pacific/Marquesas | ||
| 73 | +Mauritius Standard Time Indian/Mauritius | ||
| 74 | +Middle East Standard Time Asia/Beirut | ||
| 75 | +Montevideo Standard Time America/Montevideo | ||
| 76 | +Morocco Standard Time Africa/Casablanca | ||
| 77 | +Mountain Standard Time America/Denver | ||
| 78 | +Mountain Standard Time (Mexico) America/Mazatlan | ||
| 79 | +Myanmar Standard Time Asia/Rangoon | ||
| 80 | +N. Central Asia Standard Time Asia/Novosibirsk | ||
| 81 | +Namibia Standard Time Africa/Windhoek | ||
| 82 | +Nepal Standard Time Asia/Katmandu | ||
| 83 | +New Zealand Standard Time Pacific/Auckland | ||
| 84 | +Newfoundland Standard Time America/St_Johns | ||
| 85 | +Norfolk Standard Time Pacific/Norfolk | ||
| 86 | +North Asia East Standard Time Asia/Irkutsk | ||
| 87 | +North Asia Standard Time Asia/Krasnoyarsk | ||
| 88 | +North Korea Standard Time Asia/Pyongyang | ||
| 89 | +Omsk Standard Time Asia/Omsk | ||
| 90 | +Pacific SA Standard Time America/Santiago | ||
| 91 | +Pacific Standard Time America/Los_Angeles | ||
| 92 | +Pacific Standard Time (Mexico) America/Tijuana | ||
| 93 | +Pakistan Standard Time Asia/Karachi | ||
| 94 | +Paraguay Standard Time America/Asuncion | ||
| 95 | +Qyzylorda Standard Time Asia/Qyzylorda | ||
| 96 | +Romance Standard Time Europe/Paris | ||
| 97 | +Russia Time Zone 10 Asia/Srednekolymsk | ||
| 98 | +Russia Time Zone 11 Asia/Kamchatka | ||
| 99 | +Russia Time Zone 3 Europe/Samara | ||
| 100 | +Russian Standard Time Europe/Moscow | ||
| 101 | +SA Eastern Standard Time America/Cayenne | ||
| 102 | +SA Pacific Standard Time America/Bogota | ||
| 103 | +SA Western Standard Time America/La_Paz | ||
| 104 | +SE Asia Standard Time Asia/Bangkok | ||
| 105 | +Saint Pierre Standard Time America/Miquelon | ||
| 106 | +Sakhalin Standard Time Asia/Sakhalin | ||
| 107 | +Samoa Standard Time Pacific/Apia | ||
| 108 | +Sao Tome Standard Time Africa/Sao_Tome | ||
| 109 | +Saratov Standard Time Europe/Saratov | ||
| 110 | +Singapore Standard Time Asia/Singapore | ||
| 111 | +South Africa Standard Time Africa/Johannesburg | ||
| 112 | +South Sudan Standard Time Africa/Juba | ||
| 113 | +Sri Lanka Standard Time Asia/Colombo | ||
| 114 | +Sudan Standard Time Africa/Khartoum | ||
| 115 | +Syria Standard Time Asia/Damascus | ||
| 116 | +Taipei Standard Time Asia/Taipei | ||
| 117 | +Tasmania Standard Time Australia/Hobart | ||
| 118 | +Tocantins Standard Time America/Araguaina | ||
| 119 | +Tokyo Standard Time Asia/Tokyo | ||
| 120 | +Tomsk Standard Time Asia/Tomsk | ||
| 121 | +Tonga Standard Time Pacific/Tongatapu | ||
| 122 | +Transbaikal Standard Time Asia/Chita | ||
| 123 | +Turkey Standard Time Europe/Istanbul | ||
| 124 | +Turks And Caicos Standard Time America/Grand_Turk | ||
| 125 | +US Eastern Standard Time America/Indianapolis | ||
| 126 | +US Mountain Standard Time America/Phoenix | ||
| 127 | +UTC Etc/UTC | ||
| 128 | +UTC+12 Etc/GMT-12 | ||
| 129 | +UTC+13 Etc/GMT-13 | ||
| 130 | +UTC-02 Etc/GMT+2 | ||
| 131 | +UTC-08 Etc/GMT+8 | ||
| 132 | +UTC-09 Etc/GMT+9 | ||
| 133 | +UTC-11 Etc/GMT+11 | ||
| 134 | +Ulaanbaatar Standard Time Asia/Ulaanbaatar | ||
| 135 | +Venezuela Standard Time America/Caracas | ||
| 136 | +Vladivostok Standard Time Asia/Vladivostok | ||
| 137 | +Volgograd Standard Time Europe/Volgograd | ||
| 138 | +W. Australia Standard Time Australia/Perth | ||
| 139 | +W. Central Africa Standard Time Africa/Lagos | ||
| 140 | +W. Europe Standard Time Europe/Berlin | ||
| 141 | +W. Mongolia Standard Time Asia/Hovd | ||
| 142 | +West Asia Standard Time Asia/Tashkent | ||
| 143 | +West Bank Standard Time Asia/Hebron | ||
| 144 | +West Pacific Standard Time Pacific/Port_Moresby | ||
| 145 | +Yakutsk Standard Time Asia/Yakutsk | ||
| 146 | +Yukon Standard Time America/Whitehorse | ||
| 0 | 147 |