Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/resources/timezones/generate-timezone-map.php
12240 views
1
#!/usr/bin/env php
2
<?php
3
4
$root = dirname(dirname(dirname(__FILE__)));
5
require_once $root.'/scripts/init/init-script.php';
6
7
$xml = $root.'/externals/cldr/cldr_windows_timezones.xml';
8
$xml = Filesystem::readFile($xml);
9
$xml = new SimpleXMLElement($xml);
10
11
$result_map = array();
12
13
$ignore = array(
14
'UTC',
15
'UTC-11',
16
'UTC-02',
17
'UTC-08',
18
'UTC-09',
19
'UTC+12',
20
);
21
$ignore = array_fuse($ignore);
22
23
$zones = $xml->windowsZones->mapTimezones->mapZone;
24
foreach ($zones as $zone) {
25
$windows_name = (string)$zone['other'];
26
$target_name = (string)$zone['type'];
27
28
// Ignore the offset-based timezones from the CLDR map, since we handle
29
// these later.
30
if (isset($ignore[$windows_name])) {
31
continue;
32
}
33
34
// We've already seen this timezone so we don't need to add it to the map
35
// again.
36
if (isset($result_map[$windows_name])) {
37
continue;
38
}
39
40
$result_map[$windows_name] = $target_name;
41
}
42
43
asort($result_map);
44
45
echo id(new PhutilJSON())
46
->encodeFormatted($result_map);
47
48