ILIAS  release_8 Revision v8.24
zoneinfo_generator.php
Go to the documentation of this file.
1<?php
2
4
5const ZONEINFO = '/usr/share/zoneinfo';
6const TZ_CONVERT = 'tz_convert';
7const READLINK = 'readlink';
8
9 chdir('../../..');
10
11
12 foreach (ilCalendarUtil::_getShortTimeZoneList() as $tz_name => $tmp) {
13 $name_underscore = str_replace('/', '_', $tz_name);
14
15 if (is_link(ZONEINFO . '/' . $tz_name)) {
16 $name = exec(READLINK . ' -f ' . ZONEINFO . '/' . $tz_name);
17 } else {
18 $name = ZONEINFO . '/' . $tz_name;
19 }
20
21 exec(TZ_CONVERT . ' -o Services/Calendar/zoneinfo/' . $name_underscore . '.tmp' . ' ' . $name);
22
23 $reader = fopen('Services/Calendar/zoneinfo/' . $name_underscore . '.tmp', 'r');
24 $writer = fopen('Services/Calendar/zoneinfo/' . $name_underscore . '.ics', 'w');
25
26 $counter = 0;
27 while ($line = fgets($reader)) {
28 if (++$counter < 4) {
29 continue;
30 }
31 if ($counter == 5) {
32 fputs($writer, 'TZID:' . $tz_name . "\n");
33 } else {
34 if (substr($line, 0, 13) === 'END:VCALENDAR') {
35 break;
36 }
37 fputs($writer, $line);
38 }
39 }
40
41 fclose($reader);
42 fclose($writer);
43 unlink('Services/Calendar/zoneinfo/' . $name_underscore . '.tmp');
44
45 #echo $name_underscore.' <br />';
46 }
static _getShortTimeZoneList()
get short timezone list
if($format !==null) $name
Definition: metadata.php:247
const READLINK
const TZ_CONVERT
const ZONEINFO