first steps for better timezone management
This commit is contained in:
@@ -7,8 +7,8 @@ X-WR-CALNAME:Testkalender
|
||||
X-WR-TIMEZONE:Europe/Berlin
|
||||
X-WR-CALDESC:Nur zum testen vom Google Kalender
|
||||
BEGIN:VEVENT
|
||||
DTSTART:20121112T173000Z
|
||||
DTEND:20121116T180000Z
|
||||
DTSTART;TZID="W. Europe":20121227T100000
|
||||
DTEND;TZID="W. Europe":20121227T110000Z
|
||||
DTSTAMP:20110121T195741Z
|
||||
UID:1koigufm110c5hnq6ln57murd4@google.com
|
||||
CREATED:20110119T142901Z
|
||||
|
@@ -176,7 +176,7 @@ class ICal {
|
||||
* @return {array} array("VCALENDAR", "Begin")
|
||||
*/
|
||||
public function keyValueFromString($text) {
|
||||
preg_match("/(^[^a-z:]+[;a-zA-Z=\/]*)[:]([\w\W]*)/", $text, $matches);
|
||||
preg_match("/(^[^a-z:]+[;a-zA-Z=\/\"\']*)[:]([\w\W]*)/", $text, $matches);
|
||||
|
||||
error_log("macthes: " . count($matches). " " . $text);
|
||||
if (count($matches) == 0) {
|
||||
@@ -195,7 +195,11 @@ class ICal {
|
||||
*
|
||||
* @return {int}
|
||||
*/
|
||||
public function iCalDateToUnixTimestamp($icalDate) {
|
||||
public function iCalDateToUnixTimestamp($icalDate) {
|
||||
|
||||
/* timestring format */
|
||||
$utc = strpos("zZ",substr($icalDate, -1)) === false ? false : true;
|
||||
|
||||
$icalDate = str_replace('T', '', $icalDate);
|
||||
$icalDate = str_replace('Z', '', $icalDate);
|
||||
|
||||
@@ -206,6 +210,9 @@ class ICal {
|
||||
$pattern .= '([0-9]{0,2})'; // 5: MM
|
||||
$pattern .= '([0-9]{0,2})/'; // 6: SS
|
||||
preg_match($pattern, $icalDate, $date);
|
||||
|
||||
|
||||
|
||||
|
||||
// Unix timestamp can't represent dates before 1970
|
||||
if ($date[1] <= 1970) {
|
||||
@@ -221,11 +228,14 @@ class ICal {
|
||||
(int)$date[1]);
|
||||
|
||||
|
||||
$utcdate = new DateTime();
|
||||
$utcdate->setTimestamp($timestamp);
|
||||
$utcdate->setTimezone(new DateTimeZone($this->default_timezone));
|
||||
$utcoffset = $utcdate->getOffset();
|
||||
|
||||
if($utc) {
|
||||
$utcdate = new DateTime();
|
||||
$utcdate->setTimestamp($timestamp);
|
||||
$utcdate->setTimezone(new DateTimeZone($this->default_timezone));
|
||||
$utcoffset = $utcdate->getOffset();
|
||||
} else {
|
||||
$utcoffset = 0;
|
||||
}
|
||||
|
||||
return ($timestamp + $utcoffset);
|
||||
}
|
||||
|
Reference in New Issue
Block a user