ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
zoneinfo_generator.php
Go to the documentation of this file.
1 <?php
2 
20 
21 const ZONEINFO = '/usr/share/zoneinfo';
22 const TZ_CONVERT = 'tz_convert';
23 const READLINK = 'readlink';
24 
25 chdir('../../..');
26 
27 
28 foreach (ilCalendarUtil::_getShortTimeZoneList() as $tz_name => $tmp) {
29  $name_underscore = str_replace('/', '_', $tz_name);
30 
31  if (is_link(ZONEINFO . '/' . $tz_name)) {
32  $name = exec(READLINK . ' -f ' . ZONEINFO . '/' . $tz_name);
33  } else {
34  $name = ZONEINFO . '/' . $tz_name;
35  }
36 
37  exec(TZ_CONVERT . ' -o Services/Calendar/zoneinfo/' . $name_underscore . '.tmp' . ' ' . $name);
38 
39  $reader = fopen('components/ILIAS/Calendar/zoneinfo/' . $name_underscore . '.tmp', 'r');
40  $writer = fopen('components/ILIAS/Calendar/zoneinfo/' . $name_underscore . '.ics', 'w');
41 
42  $counter = 0;
43  while ($line = fgets($reader)) {
44  if (++$counter < 4) {
45  continue;
46  }
47  if ($counter == 5) {
48  fputs($writer, 'TZID:' . $tz_name . "\n");
49  } else {
50  if (substr($line, 0, 13) === 'END:VCALENDAR') {
51  break;
52  }
53  fputs($writer, $line);
54  }
55  }
56 
57  fclose($reader);
58  fclose($writer);
59  unlink('components/ILIAS/Calendar/zoneinfo/' . $name_underscore . '.tmp');
60 
61  #echo $name_underscore.' <br />';
62 }
const ZONEINFO
static _getShortTimeZoneList()
get short timezone list
const READLINK
const TZ_CONVERT
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...