aboutsummaryrefslogblamecommitdiffstats
path: root/vendor/sabre/vobject/bin/fetch_windows_zones.php
blob: 2361dc3093fa5238dfd9abb35e7715187ca2c0b3 (plain) (tree)
1
2
3
4
5
6
7
8
9


                  
                                                                                                                    
                                                              
 
                                                           

                                            




                                                

                                       





                                     









                                                         

                                                   
                   
                                                                             


                                                                          

                                       



                    
                                                                             

              
#!/usr/bin/env php
<?php

$windowsZonesUrl = 'https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml';
$outputFile = __DIR__.'/../lib/timezonedata/windowszones.php';

echo 'Fetching timezone map from: '.$windowsZonesUrl, "\n";

$data = file_get_contents($windowsZonesUrl);
$xml = simplexml_load_string($data);

$map = [];

foreach ($xml->xpath('//mapZone') as $mapZone) {
    $from = (string) $mapZone['other'];
    $to = (string) $mapZone['type'];

    list($to) = explode(' ', $to, 2);

    if (!isset($map[$from])) {
        $map[$from] = $to;
    }
}

ksort($map);
echo "Writing to: $outputFile\n";

$f = fopen($outputFile, 'w');
fwrite($f, "<?php\n\n");
fwrite($f, "/**\n");
fwrite($f, " * Automatically generated timezone file\n");
fwrite($f, " *\n");
fwrite($f, ' * Last update: '.date(DATE_W3C)."\n");
fwrite($f, ' * Source: '.$windowsZonesUrl."\n");
fwrite($f, " *\n");
fwrite($f, " * @copyright Copyright (C) fruux GmbH (https://fruux.com/).\n");
fwrite($f, " * @license http://sabre.io/license/ Modified BSD License\n");
fwrite($f, " */\n");
fwrite($f, "\n");
fwrite($f, 'return ');
fwrite($f, var_export($map, true).';');
fclose($f);

echo "Formatting\n";

exec(__DIR__.'/../vendor/bin/php-cs-fixer fix '.escapeshellarg($outputFile));

echo "Done\n";