use PHP 5.2+ DateTimeZone objects if available to get active daylight state

Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
master
Tanguy Pruvot 2010-10-29 02:57:37 +02:00
rodzic e0d25803d2
commit 8b5be46c25
1 zmienionych plików z 24 dodań i 13 usunięć

Wyświetl plik

@ -65,6 +65,16 @@ class SG_iCal_VTimeZone {
* @return string standard|daylight
*/
private function getActive( $ts ) {
if (class_exists('DateTimeZone')) {
//PHP >= 5.2
$tz = new DateTimeZone( $this->tzid );
$date = new DateTime("@$ts", $tz);
return ($date->format('%I') == 1) ? 'daylight' : 'standard';
} else {
if( isset($this->cache[$ts]) ) {
return $this->cache[$ts];
}
@ -82,3 +92,4 @@ class SG_iCal_VTimeZone {
return $this->cache[$ts];
}
}
}