Fix test
This commit is contained in:
parent
5eb91ca74a
commit
312b1981de
2 changed files with 33 additions and 35 deletions
|
@ -944,7 +944,7 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
|
|
||||||
if ($dt) {
|
if ($dt) {
|
||||||
if ($utc) {
|
if ($utc) {
|
||||||
$dt->setTimeZone(new \DateTimeZone('UTC'));
|
$dt->setTimeZone(new DateTimeZone('UTC'));
|
||||||
$is_utc = true;
|
$is_utc = true;
|
||||||
} else {
|
} else {
|
||||||
$is_utc = ($tz = $dt->getTimezone()) && in_array($tz->getName(), ['UTC','GMT','Z']);
|
$is_utc = ($tz = $dt->getTimezone()) && in_array($tz->getName(), ['UTC','GMT','Z']);
|
||||||
|
@ -1092,7 +1092,7 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
$ve->UID = $event['uid'];
|
$ve->UID = $event['uid'];
|
||||||
|
|
||||||
// set DTSTAMP according to RFC 5545, 3.8.7.2.
|
// set DTSTAMP according to RFC 5545, 3.8.7.2.
|
||||||
$dtstamp = !empty($event['changed']) && empty($this->method) ? $event['changed'] : new DateTime('now', new \DateTimeZone('UTC'));
|
$dtstamp = !empty($event['changed']) && empty($this->method) ? $event['changed'] : new DateTime('now', new DateTimeZone('UTC'));
|
||||||
$ve->DTSTAMP = $this->datetime_prop($cal, 'DTSTAMP', $dtstamp, true);
|
$ve->DTSTAMP = $this->datetime_prop($cal, 'DTSTAMP', $dtstamp, true);
|
||||||
|
|
||||||
// all-day events end the next day
|
// all-day events end the next day
|
||||||
|
@ -1410,12 +1410,12 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
* Returns a VTIMEZONE component for a Olson timezone identifier
|
* Returns a VTIMEZONE component for a Olson timezone identifier
|
||||||
* with daylight transitions covering the given date range.
|
* with daylight transitions covering the given date range.
|
||||||
*
|
*
|
||||||
* @param string Timezone ID as used in PHP's Date functions
|
* @param string $tzid Timezone ID as used in PHP's Date functions
|
||||||
* @param integer Unix timestamp with first date/time in this timezone
|
* @param int $from Unix timestamp with first date/time in this timezone
|
||||||
* @param integer Unix timestap with last date/time in this timezone
|
* @param int $to Unix timestap with last date/time in this timezone
|
||||||
* @param VObject\Component\VCalendar Optional VCalendar component
|
* @param VObject\Component\VCalendar Optional VCalendar component
|
||||||
*
|
*
|
||||||
* @return mixed A Sabre\VObject\Component object representing a VTIMEZONE definition
|
* @return Sabre\VObject\Component|false Object representing a VTIMEZONE definition
|
||||||
* or false if no timezone information is available
|
* or false if no timezone information is available
|
||||||
*/
|
*/
|
||||||
public static function get_vtimezone($tzid, $from = 0, $to = 0, $cal = null)
|
public static function get_vtimezone($tzid, $from = 0, $to = 0, $cal = null)
|
||||||
|
@ -1434,15 +1434,15 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
|
|
||||||
if (is_string($tzid)) {
|
if (is_string($tzid)) {
|
||||||
try {
|
try {
|
||||||
$tz = new \DateTimeZone($tzid);
|
$tz = new DateTimeZone($tzid);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
return false;
|
// do nothing
|
||||||
}
|
}
|
||||||
} elseif (is_a($tzid, '\\DateTimeZone')) {
|
} elseif ($tzid instanceof DateTimeZone) {
|
||||||
$tz = $tzid;
|
$tz = $tzid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($tz) || !is_a($tz, '\\DateTimeZone')) {
|
if (empty($tz) || !$tz instanceof DateTimeZone) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1466,9 +1466,8 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
$std = null;
|
$std = null;
|
||||||
$dst = null;
|
$dst = null;
|
||||||
$t_dst = $t_std = 0;
|
$t_dst = $t_std = 0;
|
||||||
foreach ($transitions as $i => $trans) {
|
|
||||||
$cmp = null;
|
|
||||||
|
|
||||||
|
foreach ($transitions as $i => $trans) {
|
||||||
if (!isset($tzfrom)) {
|
if (!isset($tzfrom)) {
|
||||||
$tzfrom = $trans['offset'] / 3600;
|
$tzfrom = $trans['offset'] / 3600;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1484,7 +1483,7 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
$cmp = $std;
|
$cmp = $std;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cmp) {
|
// FIXME: Imho $trans['time'] is UTC, shouldn't we consider timezone offset for DTSTART below?
|
||||||
$dt = new DateTime($trans['time']);
|
$dt = new DateTime($trans['time']);
|
||||||
$offset = $trans['offset'] / 3600;
|
$offset = $trans['offset'] / 3600;
|
||||||
|
|
||||||
|
@ -1498,7 +1497,6 @@ class libcalendaring_vcalendar implements Iterator
|
||||||
|
|
||||||
$tzfrom = $offset;
|
$tzfrom = $offset;
|
||||||
$vt->add($cmp);
|
$vt->add($cmp);
|
||||||
}
|
|
||||||
|
|
||||||
// we covered the entire date range
|
// we covered the entire date range
|
||||||
if ($std && $dst && min($t_std, $t_dst) < $from && max($t_std, $t_dst) > $to) {
|
if ($std && $dst && min($t_std, $t_dst) < $from && max($t_std, $t_dst) > $to) {
|
||||||
|
|
|
@ -584,22 +584,22 @@ class VcalendarTest extends PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
// Making sure VTIMEZOONE contains at least one STANDARD/DAYLIGHT component
|
// Making sure VTIMEZOONE contains at least one STANDARD/DAYLIGHT component
|
||||||
// when there's only one transition in specified time period (T5626)
|
// when there's only one transition in specified time period (T5626)
|
||||||
$vtz = libcalendaring_vcalendar::get_vtimezone('Europe/Istanbul', strtotime('2019-10-04T15:00:00'));
|
$vtz = libcalendaring_vcalendar::get_vtimezone('Europe/Warsaw', strtotime('2023-10-04T15:00:00'));
|
||||||
|
|
||||||
$this->assertInstanceOf('\Sabre\VObject\Component', $vtz);
|
$this->assertInstanceOf('\Sabre\VObject\Component', $vtz);
|
||||||
|
|
||||||
$dst = $vtz->select('DAYLIGHT');
|
$dst = $vtz->select('DAYLIGHT');
|
||||||
$std = $vtz->select('STANDARD');
|
$std = $vtz->select('STANDARD');
|
||||||
|
|
||||||
$this->assertEmpty($dst);
|
$this->assertCount(1, $dst);
|
||||||
$this->assertCount(1, $std);
|
$this->assertCount(2, $std);
|
||||||
|
|
||||||
$std = end($std);
|
$std = end($std);
|
||||||
$this->assertEquals('STANDARD', $std->name);
|
|
||||||
$this->assertEquals('20181009T150000', $std->DTSTART);
|
$this->assertSame('STANDARD', $std->name);
|
||||||
$this->assertEquals('+0300', $std->TZOFFSETFROM);
|
$this->assertSame('20231029T010000', (string) $std->DTSTART);
|
||||||
$this->assertEquals('+0300', $std->TZOFFSETTO);
|
$this->assertSame('+0200', (string) $std->TZOFFSETFROM);
|
||||||
$this->assertEquals('+03', $std->TZNAME);
|
$this->assertSame('+0100', (string) $std->TZOFFSETTO);
|
||||||
|
$this->assertSame('CET', (string) $std->TZNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_attachment_data($id, $event)
|
public function get_attachment_data($id, $event)
|
||||||
|
|
Loading…
Add table
Reference in a new issue