annotate vendor/sabre/vobject/bin/fetch_windows_zones.php @ 7:430dbd5346f7

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