bench.php
1 year ago
bench_freebusygenerator.php
1 year ago
bench_manipulatevcard.php
1 year ago
fetch_windows_zones.php
1 year ago
generate_vcards
1 year ago
generateicalendardata.php
1 year ago
mergeduplicates.php
1 year ago
rrulebench.php
1 year ago
vobject
1 year ago
fetch_windows_zones.php
49 lines
| 1 | #!/usr/bin/env php |
| 2 | <?php |
| 3 | |
| 4 | $windowsZonesUrl = 'https://raw.githubusercontent.com/unicode-org/cldr/master/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 | $xml = simplexml_load_string($data); |
| 11 | |
| 12 | $map = []; |
| 13 | |
| 14 | foreach ($xml->xpath('//mapZone') as $mapZone) { |
| 15 | $from = (string) $mapZone['other']; |
| 16 | $to = (string) $mapZone['type']; |
| 17 | |
| 18 | list($to) = explode(' ', $to, 2); |
| 19 | |
| 20 | if (!isset($map[$from])) { |
| 21 | $map[$from] = $to; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | ksort($map); |
| 26 | echo "Writing to: $outputFile\n"; |
| 27 | |
| 28 | $f = fopen($outputFile, 'w'); |
| 29 | fwrite($f, "<?php\n\n"); |
| 30 | fwrite($f, "/**\n"); |
| 31 | fwrite($f, " * Automatically generated timezone file\n"); |
| 32 | fwrite($f, " *\n"); |
| 33 | fwrite($f, ' * Last update: '.date(DATE_W3C)."\n"); |
| 34 | fwrite($f, ' * Source: '.$windowsZonesUrl."\n"); |
| 35 | fwrite($f, " *\n"); |
| 36 | fwrite($f, " * @copyright Copyright (C) fruux GmbH (https://fruux.com/).\n"); |
| 37 | fwrite($f, " * @license http://sabre.io/license/ Modified BSD License\n"); |
| 38 | fwrite($f, " */\n"); |
| 39 | fwrite($f, "\n"); |
| 40 | fwrite($f, 'return '); |
| 41 | fwrite($f, var_export($map, true).';'); |
| 42 | fclose($f); |
| 43 | |
| 44 | echo "Formatting\n"; |
| 45 | |
| 46 | exec(__DIR__.'/../vendor/bin/php-cs-fixer fix '.escapeshellarg($outputFile)); |
| 47 | |
| 48 | echo "Done\n"; |
| 49 |