mirror of
https://github.com/rlanvin/php-rrule.git
synced 2025-02-26 15:54:14 +01:00
Merge pull request #6 from gordonzhao/master
Return results in the same timezone as DTSTART
This commit is contained in:
commit
c8fedbbb5b
@ -1519,7 +1519,8 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
|
||||
if ( ! isset($filtered_set[$tmp]) ) {
|
||||
$occurrence = \DateTime::createFromFormat(
|
||||
'Y z',
|
||||
"$year $yearday"
|
||||
"$year $yearday",
|
||||
$this->dtstart->getTimezone()
|
||||
);
|
||||
$occurrence->setTime($time[0], $time[1], $time[2]);
|
||||
$filtered_set[$tmp] = $occurrence;
|
||||
@ -1554,7 +1555,7 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
|
||||
else {
|
||||
// normal loop, without BYSETPOS
|
||||
while ( ($yearday = current($dayset)) !== false ) {
|
||||
$occurrence = \DateTime::createFromFormat('Y z', "$year $yearday");
|
||||
$occurrence = \DateTime::createFromFormat('Y z', "$year $yearday",$this->dtstart->getTimezone());
|
||||
|
||||
while ( ($time = current($timeset)) !== false ) {
|
||||
$occurrence->setTime($time[0], $time[1], $time[2]);
|
||||
|
@ -756,17 +756,43 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
return array(
|
||||
// Daily, for 10 occurrences.
|
||||
array(
|
||||
array('freq' => 'daily', 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-03 09:00:00'),
|
||||
date_create('1997-09-04 09:00:00'),
|
||||
date_create('1997-09-05 09:00:00'),
|
||||
date_create('1997-09-06 09:00:00'),
|
||||
date_create('1997-09-07 09:00:00'),
|
||||
date_create('1997-09-08 09:00:00'),
|
||||
date_create('1997-09-09 09:00:00'),
|
||||
date_create('1997-09-10 09:00:00'),
|
||||
date_create('1997-09-11 09:00:00'))
|
||||
array('freq' => 'daily', 'count' => 10, 'dtstart' => date_create('1997-09-02 09:00:00',new DateTimeZone('Australia/Sydney'))),
|
||||
array(date_create('1997-09-02 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-04 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-05 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-06 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-07 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-08 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-09 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-10 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-11 09:00:00',new DateTimeZone('Australia/Sydney')))
|
||||
),
|
||||
array(
|
||||
array('freq' => 'daily', 'count' => 10, 'dtstart' => date_create('2016-10-02 09:00:00',new DateTimeZone('Australia/Sydney'))),
|
||||
array(date_create('2016-10-02 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-03 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-04 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-05 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-06 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-07 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-08 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-09 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-10 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-10-11 09:00:00',new DateTimeZone('Australia/Sydney')))
|
||||
),
|
||||
array(
|
||||
array('freq' => 'daily', 'count' => 10, 'dtstart' => date_create('2016-04-02 09:00:00',new DateTimeZone('Australia/Sydney'))),
|
||||
array(date_create('2016-04-02 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-03 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-04 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-05 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-06 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-07 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-08 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-09 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-10 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('2016-04-11 09:00:00',new DateTimeZone('Australia/Sydney')))
|
||||
),
|
||||
// Daily until December 24, 1997
|
||||
array(
|
||||
@ -1227,65 +1253,65 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
),
|
||||
// Every hour and a half for 4 occurrences.
|
||||
array(
|
||||
array('freq' => 'MINUTELY', 'interval' => 90, 'count' => 4, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-02 10:30:00'),
|
||||
date_create('1997-09-02 12:00:00'),
|
||||
date_create('1997-09-02 13:30:00'))
|
||||
array('freq' => 'MINUTELY', 'interval' => 90, 'count' => 4, 'dtstart' => date_create('1997-09-02 09:00:00',new DateTimeZone('Australia/Sydney'))),
|
||||
array(date_create('1997-09-02 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 10:30:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 12:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 13:30:00',new DateTimeZone('Australia/Sydney')))
|
||||
),
|
||||
// Every 20 minutes from 9:00 AM to 4:40 PM for two days.
|
||||
array(
|
||||
array('freq' => 'MINUTELY', 'interval' => 20, 'count' => 48,
|
||||
'byhour' => range(9,16), 'byminute' => '0,20,40',
|
||||
'dtstart' => '1997-09-02 09:00:00'), array(
|
||||
date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-02 09:20:00'),
|
||||
date_create('1997-09-02 09:40:00'),
|
||||
date_create('1997-09-02 10:00:00'),
|
||||
date_create('1997-09-02 10:20:00'),
|
||||
date_create('1997-09-02 10:40:00'),
|
||||
date_create('1997-09-02 11:00:00'),
|
||||
date_create('1997-09-02 11:20:00'),
|
||||
date_create('1997-09-02 11:40:00'),
|
||||
date_create('1997-09-02 12:00:00'),
|
||||
date_create('1997-09-02 12:20:00'),
|
||||
date_create('1997-09-02 12:40:00'),
|
||||
date_create('1997-09-02 13:00:00'),
|
||||
date_create('1997-09-02 13:20:00'),
|
||||
date_create('1997-09-02 13:40:00'),
|
||||
date_create('1997-09-02 14:00:00'),
|
||||
date_create('1997-09-02 14:20:00'),
|
||||
date_create('1997-09-02 14:40:00'),
|
||||
date_create('1997-09-02 15:00:00'),
|
||||
date_create('1997-09-02 15:20:00'),
|
||||
date_create('1997-09-02 15:40:00'),
|
||||
date_create('1997-09-02 16:00:00'),
|
||||
date_create('1997-09-02 16:20:00'),
|
||||
date_create('1997-09-02 16:40:00'),
|
||||
date_create('1997-09-03 09:00:00'),
|
||||
date_create('1997-09-03 09:20:00'),
|
||||
date_create('1997-09-03 09:40:00'),
|
||||
date_create('1997-09-03 10:00:00'),
|
||||
date_create('1997-09-03 10:20:00'),
|
||||
date_create('1997-09-03 10:40:00'),
|
||||
date_create('1997-09-03 11:00:00'),
|
||||
date_create('1997-09-03 11:20:00'),
|
||||
date_create('1997-09-03 11:40:00'),
|
||||
date_create('1997-09-03 12:00:00'),
|
||||
date_create('1997-09-03 12:20:00'),
|
||||
date_create('1997-09-03 12:40:00'),
|
||||
date_create('1997-09-03 13:00:00'),
|
||||
date_create('1997-09-03 13:20:00'),
|
||||
date_create('1997-09-03 13:40:00'),
|
||||
date_create('1997-09-03 14:00:00'),
|
||||
date_create('1997-09-03 14:20:00'),
|
||||
date_create('1997-09-03 14:40:00'),
|
||||
date_create('1997-09-03 15:00:00'),
|
||||
date_create('1997-09-03 15:20:00'),
|
||||
date_create('1997-09-03 15:40:00'),
|
||||
date_create('1997-09-03 16:00:00'),
|
||||
date_create('1997-09-03 16:20:00'),
|
||||
date_create('1997-09-03 16:40:00'))
|
||||
'dtstart' => date_create('1997-09-02 09:00:00',new DateTimeZone('Australia/Sydney'))), array(
|
||||
date_create('1997-09-02 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 09:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 09:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 10:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 10:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 10:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 11:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 11:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 11:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 12:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 12:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 12:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 13:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 13:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 13:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 14:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 14:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 14:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 15:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 15:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 15:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 16:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 16:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-02 16:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 09:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 09:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 09:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 10:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 10:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 10:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 11:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 11:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 11:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 12:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 12:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 12:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 13:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 13:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 13:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 14:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 14:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 14:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 15:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 15:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 15:40:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 16:00:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 16:20:00',new DateTimeZone('Australia/Sydney')),
|
||||
date_create('1997-09-03 16:40:00',new DateTimeZone('Australia/Sydney')))
|
||||
),
|
||||
// An example where the days generated makes a difference because of wkst.
|
||||
array(array('freq' => 'WEEKLY', 'interval' => 2, 'count' => 4,
|
||||
|
Loading…
x
Reference in New Issue
Block a user