1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2025-02-20 09:54:16 +01:00

Change timezone names for PHP <= 5.4

This commit is contained in:
rlanvin 2016-08-07 15:05:26 +03:00
parent 0be4b1fb50
commit fe83f6de05
2 changed files with 6 additions and 7 deletions

View File

@ -558,10 +558,10 @@ class RRule implements RRuleInterface
// handle unsupported timezones like "+02:00"
// we convert them to UTC to generate a valid string
// note: there is possibly other weird timezones out there that we should catch
$dtstart->setTimezone(new \DateTimeZone('Z'));
$timezone_name = 'Z';
$dtstart->setTimezone(new \DateTimeZone('UTC'));
$timezone_name = 'UTC';
}
if ( $timezone_name == 'Z' ) {
if ( in_array($timezone_name, ['UTC','GMT','Z']) ) {
$str = sprintf(
"DTSTART:%s\nRRULE:",
$dtstart->format('Ymd\THis\Z')
@ -1170,7 +1170,7 @@ class RRule implements RRuleInterface
try {
if ( is_integer($date) ) {
$date = \DateTime::createFromFormat('U',$date);
$date->setTimezone(new \DateTimeZone('Z')); // default is +00:00 (see issue #15)
$date->setTimezone(new \DateTimeZone('UTC')); // default is +00:00 (see issue #15)
}
else {
$date = new \DateTime($date);

View File

@ -1807,8 +1807,7 @@ class RRuleTest extends PHPUnit_Framework_TestCase
$str = $rrule->rfcString();
$new_rrule = new RRule($str);
}
/* todo: only run this test for php > 5.4
public function testUnsupportedTimezoneConvertedToUtc()
{
$date = new DateTime('2016-07-08 12:00:00', new DateTimeZone('+06:00'));
@ -1822,7 +1821,7 @@ class RRuleTest extends PHPUnit_Framework_TestCase
$this->assertTrue(strpos($str, '20160708T060000Z')!== false);
$new_rrule = new RRule($str);
}
*/
public function rfcStringsWithoutTimezone()
{
return array(