7
|
1 #!/usr/bin/env php
|
|
2 <?php
|
|
3
|
|
4 $windowsZonesUrl = 'http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml';
|
|
5 $outputFile = __DIR__ . '/../lib/timezonedata/windowszones.php';
|
|
6
|
|
7 echo "Fetching timezone map from: " . $windowsZonesUrl, "\n";
|
|
8
|
|
9 $data = file_get_contents($windowsZonesUrl);
|
|
10
|
|
11 $xml = simplexml_load_string($data);
|
|
12
|
|
13 $map = [];
|
|
14
|
|
15 foreach($xml->xpath('//mapZone') as $mapZone) {
|
|
16
|
|
17 $from = (string)$mapZone['other'];
|
|
18 $to = (string)$mapZone['type'];
|
|
19
|
|
20 list($to) = explode(' ', $to, 2);
|
|
21
|
|
22 if (!isset($map[$from])) {
|
|
23 $map[$from] = $to;
|
|
24 }
|
|
25
|
|
26 }
|
|
27
|
|
28 ksort($map);
|
|
29 echo "Writing to: $outputFile\n";
|
|
30
|
|
31 $f = fopen($outputFile,'w');
|
|
32 fwrite($f, "<?php\n\n");
|
|
33 fwrite($f, "/**\n");
|
|
34 fwrite($f, " * Automatically generated timezone file\n");
|
|
35 fwrite($f, " *\n");
|
|
36 fwrite($f, " * Last update: " . date(DATE_W3C) . "\n");
|
|
37 fwrite($f, " * Source: " .$windowsZonesUrl . "\n");
|
|
38 fwrite($f, " *\n");
|
|
39 fwrite($f, " * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).\n");
|
|
40 fwrite($f, " * @license http://sabre.io/license/ Modified BSD License\n");
|
|
41 fwrite($f, " */\n");
|
|
42 fwrite($f, "\n");
|
|
43 fwrite($f, "return ");
|
|
44 fwrite($f, var_export($map, true) . ';');
|
|
45 fclose($f);
|
|
46
|
|
47 echo "Done\n";
|