r28288 - in /trunk/calendar/inc: class.calendar_ical.inc.php class.calendar_timezones.inc.php

View: New views
1 Messages — Rating Filter:   Alert me  

r28288 - in /trunk/calendar/inc: class.calendar_ical.inc.php class.calendar_timezones.inc.php

by ralfbecker :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Author: ralfbecker
Date: Tue Nov 10 21:07:33 2009
New Revision: 28288

URL: http://www.egroupware.org/viewvc/egroupware?rev=28288&view=rev
Log:
new static calendar_timezones::DateTimeZone($tzid) method returning a
DateTimeZone object resolving by PHP not supported Windows timezones
with their standard alias

Modified:
    trunk/calendar/inc/class.calendar_ical.inc.php
    trunk/calendar/inc/class.calendar_timezones.inc.php

Modified: trunk/calendar/inc/class.calendar_ical.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar_ical.inc.php?rev=28288&r1=28287&r2=28288&view=diff
==============================================================================
--- trunk/calendar/inc/class.calendar_ical.inc.php (original)
+++ trunk/calendar/inc/class.calendar_ical.inc.php Tue Nov 10 21:07:33 2009
@@ -752,7 +752,7 @@
  static $timezone_tzid;
  if (is_null($timezone) || $timezone_tzid != $tzid)
  {
- $timezone = new DateTimeZone($timezone_tzid = $tzid);
+ $timezone = calendar_timezones::DateTimeZone($timezone_tzid = $tzid);
  }
  $time->setTimezone($timezone);
  $params['TZID'] = $tzid;
@@ -1507,7 +1507,7 @@
  {
  try
  {
- $tz = new DateTimeZone($attributes['params']['TZID']);
+ $tz = calendar_timezones::DateTimeZone($attributes['params']['TZID']);
  $event['tzid'] = $tz->getName();
  }
  catch(Exception $e)

Modified: trunk/calendar/inc/class.calendar_timezones.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/calendar/inc/class.calendar_timezones.inc.php?rev=28288&r1=28287&r2=28288&view=diff
==============================================================================
--- trunk/calendar/inc/class.calendar_timezones.inc.php (original)
+++ trunk/calendar/inc/class.calendar_timezones.inc.php Tue Nov 10 21:07:33 2009
@@ -54,6 +54,24 @@
  * @var array tzid => id
  */
  protected static $tz2id = array();
+
+ /**
+ * Get DateTimeZone object for a given TZID
+ *
+ * We use our database to replace eg. Windows timezones not understood by PHP with their standard TZID
+ *
+ * @param string $tzid
+ * @return DateTimeZone
+ * @throws Exception if called with an unknown TZID
+ */
+ public function DateTimeZone($tzid)
+ {
+ if (($id = self::tz2id($tzid,'alias')))
+ {
+ $tzid = self::id2tz($id);
+ }
+ return new DateTimeZone($tzid);
+ }
 
  /**
  * Get the nummeric id (or other data) for a given TZID
@@ -242,6 +260,36 @@
  echo '<h3>'.count($found).' found, '.count($not_found)." <b>NOT</b> found</h3>\n";
 
  if ($not_found) echo "<pre>\n\$no_vtimezone = array(\n\t'".implode("',\n\t'",$not_found)."',\n);\n</pre>\n";
+
+ echo "<h3>Testing availability of PHP support for each TZID supported by EGroupware's timezone database:</h3>\n";
+ foreach($GLOBALS['egw']->db->select('egw_cal_timezones','*',false,__LINE__,__FILE__,false,'','calendar') as $row)
+ {
+ try
+ {
+ $timezone = new DateTimeZone($row['tz_tzid']);
+ //$timezone = calendar_timezones::DateTimeZone($row['tz_tzid']);
+ echo $row['tz_tzid'].": available<br />\n";
+ }
+ catch(Exception $e)
+ {
+ if (($id = calendar_timezones::tz2id($row['tz_tzid'],'alias')) &&
+ ($alias = calendar_timezones::id2tz($id)))
+ {
+
+ try
+ {
+ $timezone = new DateTimeZone($alias);
+ echo $row['tz_tzid']."='$alias': available through <b>alias</b><br />\n";
+ unset($e);
+ }
+ catch(Exception $e)
+ {
+ // ignore
+ }
+ }
+ if (isset($e)) echo $row['tz_tzid'].": <b>NOT</b> available<br />\n";
+ }
+ }
 }
 else*/
 calendar_timezones::init_static();


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
eGroupWare-cvs mailing list
eGroupWare-cvs@...
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs