parent
3835730dcb
commit
2e87df7be8
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@ |
||||
#!/usr/bin/env php |
||||
<?php |
||||
|
||||
$windowsZonesUrl = 'http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml'; |
||||
$outputFile = __DIR__ . '/../lib/Sabre/VObject/timezonedata/windowszones.php'; |
||||
|
||||
echo "Fetching timezone map from: " . $windowsZonesUrl, "\n"; |
||||
|
||||
$data = file_get_contents($windowsZonesUrl); |
||||
|
||||
$xml = simplexml_load_string($data); |
||||
|
||||
$map = []; |
||||
|
||||
foreach($xml->xpath('//mapZone') as $mapZone) { |
||||
|
||||
$from = (string)$mapZone['other']; |
||||
$to = (string)$mapZone['type']; |
||||
|
||||
list($to) = explode(' ', $to, 2); |
||||
|
||||
if (!isset($map[$from])) { |
||||
$map[$from] = $to; |
||||
} |
||||
|
||||
} |
||||
|
||||
ksort($map); |
||||
echo "Writing to: $outputFile\n"; |
||||
|
||||
$f = fopen($outputFile,'w'); |
||||
fwrite($f, "<?php\n\n");
|
||||
fwrite($f, "/**\n"); |
||||
fwrite($f, " * Automatically generated timezone file\n"); |
||||
fwrite($f, " *\n"); |
||||
fwrite($f, " * Last update: " . date(DATE_W3C) . "\n"); |
||||
fwrite($f, " * Source: " .$windowsZonesUrl . "\n"); |
||||
fwrite($f, " *\n"); |
||||
fwrite($f, " * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/).\n"); |
||||
fwrite($f, " * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License\n"); |
||||
fwrite($f, " */\n"); |
||||
fwrite($f, "\n"); |
||||
fwrite($f, "return "); |
||||
fwrite($f, var_export($map, true) . ';'); |
||||
fclose($f); |
||||
|
||||
echo "Done\n"; |
||||
@ -1,58 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Sabre\VObject; |
||||
|
||||
use |
||||
DateTime; |
||||
|
||||
class RecurrenceIteratorByMonthInDailyTest extends \PHPUnit_Framework_TestCase { |
||||
|
||||
/** |
||||
* This tests the expansion of dates with DAILY frequency in RRULE with BYMONTH restrictions |
||||
*/ |
||||
function testExpand() { |
||||
|
||||
$ics = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
PRODID:-//Apple Inc.//iCal 4.0.4//EN |
||||
CALSCALE:GREGORIAN |
||||
BEGIN:VEVENT |
||||
TRANSP:OPAQUE |
||||
DTEND:20070925T183000Z |
||||
UID:uuid |
||||
DTSTAMP:19700101T000000Z |
||||
LOCATION: |
||||
DESCRIPTION: |
||||
STATUS:CONFIRMED |
||||
SEQUENCE:18 |
||||
SUMMARY:Stuff |
||||
DTSTART:20070925T160000Z |
||||
CREATED:20071004T144642Z |
||||
RRULE:FREQ=DAILY;BYMONTH=9,10;BYDAY=SU |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
ICS; |
||||
|
||||
$vcal = Reader::read($ics); |
||||
$this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); |
||||
|
||||
$vcal->expand(new DateTime('2013-09-28'), new DateTime('2014-09-11')); |
||||
|
||||
foreach ($vcal->VEVENT as $event) { |
||||
$dates[] = $event->DTSTART->getValue(); |
||||
} |
||||
|
||||
$expectedDates = array( |
||||
"20130929T160000Z", |
||||
"20131006T160000Z", |
||||
"20131013T160000Z", |
||||
"20131020T160000Z", |
||||
"20131027T160000Z", |
||||
"20140907T160000Z" |
||||
); |
||||
|
||||
$this->assertEquals($expectedDates, $dates, 'Recursed dates are restricted by month'); |
||||
} |
||||
|
||||
} |
||||
@ -1,51 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Sabre\VObject; |
||||
|
||||
class RecurrenceIteratorFifthTuesdayProblemTest extends \PHPUnit_Framework_TestCase { |
||||
|
||||
/** |
||||
* A pretty slow test. Had to be marked as 'medium' for phpunit to not die |
||||
* after 1 second. Would be good to optimize later. |
||||
* |
||||
* @medium |
||||
*/ |
||||
function testGetDTEnd() { |
||||
|
||||
$ics = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
PRODID:-//Apple Inc.//iCal 4.0.4//EN |
||||
CALSCALE:GREGORIAN |
||||
BEGIN:VEVENT |
||||
TRANSP:OPAQUE |
||||
DTEND;TZID=America/New_York:20070925T170000 |
||||
UID:uuid |
||||
DTSTAMP:19700101T000000Z |
||||
LOCATION: |
||||
DESCRIPTION: |
||||
STATUS:CONFIRMED |
||||
SEQUENCE:18 |
||||
SUMMARY:Stuff |
||||
DTSTART;TZID=America/New_York:20070925T160000 |
||||
CREATED:20071004T144642Z |
||||
RRULE:FREQ=MONTHLY;INTERVAL=1;UNTIL=20071030T035959Z;BYDAY=5TU |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
ICS; |
||||
|
||||
$vObject = Reader::read($ics); |
||||
$it = new RecurrenceIterator($vObject, (string)$vObject->VEVENT->UID); |
||||
|
||||
while($it->valid()) { |
||||
$it->next(); |
||||
} |
||||
|
||||
// If we got here, it means we were successful. The bug that was in the |
||||
// system before would fail on the 5th tuesday of the month, if the 5th |
||||
// tuesday did not exist. |
||||
$this->assertTrue(true); |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,62 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Sabre\VObject; |
||||
|
||||
use |
||||
DateTime, |
||||
DateTimeZone; |
||||
|
||||
/** |
||||
* This is a unittest for Issue #53. |
||||
*/ |
||||
class RecurrenceIteratorIncorrectExpandTest extends \PHPUnit_Framework_TestCase { |
||||
|
||||
function testExpand() { |
||||
|
||||
$input = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
BEGIN:VEVENT |
||||
UID:foo |
||||
DTSTART:20130711T050000Z |
||||
DTEND:20130711T053000Z |
||||
RRULE:FREQ=DAILY;INTERVAL=1;COUNT=2 |
||||
END:VEVENT |
||||
BEGIN:VEVENT |
||||
UID:foo |
||||
DTSTART:20130719T050000Z |
||||
DTEND:20130719T053000Z |
||||
RECURRENCE-ID:20130712T050000Z |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
ICS; |
||||
|
||||
$vcal = Reader::read($input); |
||||
$this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); |
||||
|
||||
$vcal->expand(new DateTime('2011-01-01'), new DateTime('2014-01-01')); |
||||
|
||||
$result = $vcal->serialize(); |
||||
|
||||
$output = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
BEGIN:VEVENT |
||||
UID:foo |
||||
DTSTART:20130711T050000Z |
||||
DTEND:20130711T053000Z |
||||
END:VEVENT |
||||
BEGIN:VEVENT |
||||
UID:foo |
||||
DTSTART:20130719T050000Z |
||||
DTEND:20130719T053000Z |
||||
RECURRENCE-ID:20130712T050000Z |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
|
||||
ICS; |
||||
$this->assertEquals($output, str_replace("\r", "", $result)); |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,97 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Sabre\VObject; |
||||
|
||||
use |
||||
DateTime, |
||||
DateTimeZone, |
||||
Sabre\VObject\Component\VCalendar; |
||||
|
||||
class RecurrenceIteratorInfiniteLoopProblemTest extends \PHPUnit_Framework_TestCase { |
||||
|
||||
public function setUp() { |
||||
|
||||
$this->vcal = new VCalendar(); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* This bug came from a Fruux customer. This would result in a never-ending |
||||
* request. |
||||
*/ |
||||
function testFastForwardTooFar() { |
||||
|
||||
$ev = $this->vcal->createComponent('VEVENT'); |
||||
$ev->DTSTART = '20090420T180000Z'; |
||||
$ev->RRULE = 'FREQ=WEEKLY;BYDAY=MO;UNTIL=20090704T205959Z;INTERVAL=1'; |
||||
|
||||
$this->assertFalse($ev->isInTimeRange(new DateTime('2012-01-01 12:00:00'),new DateTime('3000-01-01 00:00:00'))); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Different bug, also likely an infinite loop. |
||||
*/ |
||||
function testYearlyByMonthLoop() { |
||||
|
||||
$ev = $this->vcal->createComponent('VEVENT'); |
||||
$ev->UID = 'uuid'; |
||||
$ev->DTSTART = '20120101T154500'; |
||||
$ev->DTSTART['TZID'] = 'Europe/Berlin'; |
||||
$ev->RRULE = 'FREQ=YEARLY;INTERVAL=1;UNTIL=20120203T225959Z;BYMONTH=2;BYSETPOS=1;BYDAY=SU,MO,TU,WE,TH,FR,SA'; |
||||
$ev->DTEND = '20120101T164500'; |
||||
$ev->DTEND['TZID'] = 'Europe/Berlin'; |
||||
|
||||
// This recurrence rule by itself is a yearly rule that should happen |
||||
// every february. |
||||
// |
||||
// The BYDAY part expands this to every day of the month, but the |
||||
// BYSETPOS limits this to only the 1st day of the month. Very crazy |
||||
// way to specify this, and could have certainly been a lot easier. |
||||
$this->vcal->add($ev); |
||||
|
||||
$it = new RecurrenceIterator($this->vcal,'uuid'); |
||||
$it->fastForward(new DateTime('2012-01-29 23:00:00', new DateTimeZone('UTC'))); |
||||
|
||||
$collect = array(); |
||||
|
||||
while($it->valid()) { |
||||
$collect[] = $it->getDTSTART(); |
||||
if ($it->getDTSTART() > new DateTime('2013-02-05 22:59:59', new DateTimeZone('UTC'))) { |
||||
break; |
||||
} |
||||
$it->next(); |
||||
|
||||
} |
||||
|
||||
$this->assertEquals( |
||||
array(new DateTime('2012-02-01 15:45:00', new DateTimeZone('Europe/Berlin'))), |
||||
$collect |
||||
); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* Something, somewhere produced an ics with an interval set to 0. Because |
||||
* this means we increase the current day (or week, month) by 0, this also |
||||
* results in an infinite loop. |
||||
* |
||||
* @expectedException InvalidArgumentException |
||||
* @return void |
||||
*/ |
||||
function testZeroInterval() { |
||||
|
||||
$ev = $this->vcal->createComponent('VEVENT'); |
||||
$ev->UID = 'uuid'; |
||||
$ev->DTSTART = '20120824T145700Z'; |
||||
$ev->RRULE = 'FREQ=YEARLY;INTERVAL=0'; |
||||
$this->vcal->add($ev); |
||||
|
||||
$it = new RecurrenceIterator($this->vcal,'uuid'); |
||||
$it->fastForward(new DateTime('2013-01-01 23:00:00', new DateTimeZone('UTC'))); |
||||
|
||||
// if we got this far.. it means we are no longer infinitely looping |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,30 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Sabre\VObject; |
||||
|
||||
class RecurrenceIteratorMinusOneProblemTest extends \PHPUnit_Framework_TestCase { |
||||
|
||||
function testMinusOne() { |
||||
|
||||
$ics = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
BEGIN:VEVENT |
||||
DTSTAMP:20120314T203127Z |
||||
UID:foo |
||||
SUMMARY:foo |
||||
RRULE:FREQ=YEARLY;UNTIL=20120314 |
||||
DTSTART;VALUE=DATE:20120315 |
||||
DTEND;VALUE=DATE:20120316 |
||||
SEQUENCE:1 |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
ICS; |
||||
|
||||
$vObject = Reader::read($ics); |
||||
$it = new RecurrenceIterator($vObject, (string)$vObject->VEVENT->UID); |
||||
|
||||
$this->assertTrue($it->valid()); |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -1,63 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace Sabre\VObject; |
||||
|
||||
use |
||||
DateTime, |
||||
DateTimeZone; |
||||
|
||||
class RecurrenceIteratorMissingOverriddenTest extends \PHPUnit_Framework_TestCase { |
||||
|
||||
function testExpand() { |
||||
|
||||
$input = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
BEGIN:VEVENT |
||||
UID:foo |
||||
DTSTART:20130727T120000Z |
||||
DURATION:PT1H |
||||
RRULE:FREQ=DAILY;COUNT=2 |
||||
SUMMARY:A |
||||
END:VEVENT |
||||
BEGIN:VEVENT |
||||
RECURRENCE-ID:20130728T120000Z |
||||
UID:foo |
||||
DTSTART:20140101T120000Z |
||||
DURATION:PT1H |
||||
SUMMARY:B |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
ICS; |
||||
|
||||
$vcal = Reader::read($input); |
||||
$this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal); |
||||
|
||||
$vcal->expand(new DateTime('2011-01-01'), new DateTime('2015-01-01')); |
||||
|
||||
$result = $vcal->serialize(); |
||||
|
||||
$output = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
BEGIN:VEVENT |
||||
UID:foo |
||||
DTSTART:20130727T120000Z |
||||
DURATION:PT1H |
||||
SUMMARY:A |
||||
END:VEVENT |
||||
BEGIN:VEVENT |
||||
RECURRENCE-ID:20130728T120000Z |
||||
UID:foo |
||||
DTSTART:20140101T120000Z |
||||
DURATION:PT1H |
||||
SUMMARY:B |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
|
||||
ICS; |
||||
$this->assertEquals($output, str_replace("\r","",$result)); |
||||
|
||||
} |
||||
|
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -1,39 +0,0 @@ |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
X-WR-TIMEZONE:America/New_York |
||||
PRODID:-//www.churchcommunitybuilder.com//Church Community Builder//EN |
||||
CALSCALE:GREGORIAN |
||||
METHOD:PUBLISH |
||||
X-WR-CALNAME:Test Event |
||||
BEGIN:VTIMEZONE |
||||
TZID:America/New_York |
||||
X-LIC-LOCATION:America/New_York |
||||
BEGIN:DAYLIGHT |
||||
TZOFFSETFROM:-0500 |
||||
TZOFFSETTO:-0400 |
||||
TZNAME:EDT |
||||
DTSTART:19700308T020000 |
||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU |
||||
END:DAYLIGHT |
||||
BEGIN:STANDARD |
||||
TZOFFSETFROM:-0400 |
||||
TZOFFSETTO:-0500 |
||||
TZNAME:EST |
||||
DTSTART:19701101T020000 |
||||
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU |
||||
END:STANDARD |
||||
END:VTIMEZONE |
||||
BEGIN:VEVENT |
||||
UID:10621-1440@ccbchurch.com |
||||
DTSTART;TZID=America/New_York:20130923T183000 |
||||
DTEND;TZID=America/New_York:20130923T203000 |
||||
DTSTAMP:20131216T170211 |
||||
RRULE:FREQ=WEEKLY;UNTIL=20131118T183000 |
||||
CREATED:20130423T161111 |
||||
DESCRIPTION:Test Event ending November 11, 2013 |
||||
LAST-MODIFIED:20131126T163428 |
||||
SEQUENCE:1387231331 |
||||
SUMMARY:Test |
||||
TRANSP:OPAQUE |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
@ -1,55 +0,0 @@ |
||||
<?php |
||||
namespace Sabre\VObject; |
||||
|
||||
class RecurrenceIteratorUntilRespectsTimezoneTest extends \PHPUnit_Framework_TestCase { |
||||
public function testUntilBeginHasTimezone() { |
||||
$filepath = realpath(__DIR__ . "/."); |
||||
$event = Reader::read(file_get_contents($filepath . "/RecurrenceIteratorUntilRespectsTimezoneTest.ics")); |
||||
|
||||
$ri = new RecurrenceIterator($event, "10621-1440@ccbchurch.com"); |
||||
$this->assertEquals("America/New_York", $ri->until->getTimezone()->getName()); |
||||
} |
||||
|
||||
public function testUntilEndingInZIsUtc() |
||||
{ |
||||
$ics_data = <<<ICS |
||||
BEGIN:VCALENDAR |
||||
VERSION:2.0 |
||||
PRODID:-//Apple Inc.//Mac OS X 10.9//EN |
||||
CALSCALE:GREGORIAN |
||||
BEGIN:VTIMEZONE |
||||
TZID:America/Chicago |
||||
BEGIN:DAYLIGHT |
||||
TZOFFSETFROM:-0600 |
||||
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU |
||||
DTSTART:20070311T020000 |
||||
TZNAME:CDT |
||||
TZOFFSETTO:-0500 |
||||
END:DAYLIGHT |
||||
BEGIN:STANDARD |
||||
TZOFFSETFROM:-0500 |
||||
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU |
||||
DTSTART:20071104T020000 |
||||
TZNAME:CST |
||||
TZOFFSETTO:-0600 |
||||
END:STANDARD |
||||
END:VTIMEZONE |
||||
BEGIN:VEVENT |
||||
CREATED:20131216T214410Z |
||||
UID:D33B6D78-A214-4752-8659-9EE718D5AB8D |
||||
RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20131119T065959Z |
||||
DTEND;TZID=America/Chicago:20130923T203000 |
||||
TRANSP:OPAQUE |
||||
SUMMARY:Test Financial Peace |
||||
DTSTART;TZID=America/Chicago:20130923T183000 |
||||
DTSTAMP:20131216T215922Z |
||||
SEQUENCE:28 |
||||
END:VEVENT |
||||
END:VCALENDAR |
||||
ICS; |
||||
$event = Reader::read($ics_data); |
||||
$ri = new RecurrenceIterator($event, "D33B6D78-A214-4752-8659-9EE718D5AB8D"); |
||||
$this->assertEquals("UTC", $ri->until->getTimezone()->getName()); |
||||
} |
||||
} |
||||
|
||||
Loading…
Reference in new issue