aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/bin/generateicalendardata.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/vobject/bin/generateicalendardata.php')
-rwxr-xr-xvendor/sabre/vobject/bin/generateicalendardata.php41
1 files changed, 19 insertions, 22 deletions
diff --git a/vendor/sabre/vobject/bin/generateicalendardata.php b/vendor/sabre/vobject/bin/generateicalendardata.php
index 92c8c106d..dfcf18780 100755
--- a/vendor/sabre/vobject/bin/generateicalendardata.php
+++ b/vendor/sabre/vobject/bin/generateicalendardata.php
@@ -3,7 +3,7 @@
use Sabre\VObject;
-if ($argc<2) {
+if ($argc < 2) {
$cmd = $argv[0];
fwrite(STDERR, <<<HI
Fruux test data generator
@@ -29,49 +29,47 @@ include __DIR__ . '/../vendor/autoload.php';
fwrite(STDERR, "Generating " . $events . " events\n");
-$currentDate = new DateTime('-' . round($events/2) . ' days');
+$currentDate = new DateTime('-' . round($events / 2) . ' days');
-$calendar = VObject\Component::create('VCALENDAR');
-$calendar->version = '2.0';
-$calendar->calscale = 'GREGORIAN';
+$calendar = new VObject\Component\VCalendar();
-$ii=0;
+$ii = 0;
-while($ii < $events) {
+while ($ii < $events) {
$ii++;
- $event = VObject\Component::create('VEVENT');
+ $event = $calendar->add('VEVENT');
$event->DTSTART = 'bla';
$event->SUMMARY = 'Event #' . $ii;
$event->UID = md5(microtime(true));
- $doctorRandom = mt_rand(1,1000);
+ $doctorRandom = mt_rand(1, 1000);
- switch($doctorRandom) {
+ switch ($doctorRandom) {
// All-day event
- case 1 :
+ case 1 :
$event->DTEND = 'bla';
$dtStart = clone $currentDate;
$dtEnd = clone $currentDate;
- $dtEnd->modify('+' . mt_rand(1,3) . ' days');
- $event->DTSTART->setDateTime($dtStart, VObject\Property\DateTime::DATE);
- $event->DTEND->setDateTime($dtEnd, VObject\Property\DateTime::DATE);
+ $dtEnd->modify('+' . mt_rand(1, 3) . ' days');
+ $event->DTSTART->setDateTime($dtStart);
+ $event->DTSTART['VALUE'] = 'DATE';
+ $event->DTEND->setDateTime($dtEnd);
break;
case 2 :
- $event->RRULE = 'FREQ=DAILY;COUNT=' . mt_rand(1,10);
+ $event->RRULE = 'FREQ=DAILY;COUNT=' . mt_rand(1, 10);
// No break intentional
default :
$dtStart = clone $currentDate;
- $dtStart->setTime(mt_rand(1,23), mt_rand(0,59), mt_rand(0,59));
- $event->DTSTART->setDateTime($dtStart, VObject\Property\DateTime::UTC);
- $event->DURATION = 'PT'.mt_rand(1,3).'H';
+ $dtStart->setTime(mt_rand(1, 23), mt_rand(0, 59), mt_rand(0, 59));
+ $event->DTSTART->setDateTime($dtStart);
+ $event->DURATION = 'PT' . mt_rand(1, 3) . 'H';
break;
}
- $calendar->add($event);
- $currentDate->modify('+ ' . mt_rand(0,3) . ' days');
+ $currentDate->modify('+ ' . mt_rand(0, 3) . ' days');
}
fwrite(STDERR, "Validating\n");
@@ -79,7 +77,7 @@ fwrite(STDERR, "Validating\n");
$result = $calendar->validate();
if ($result) {
fwrite(STDERR, "Errors!\n");
- fwrite(STDERR, print_r($result,true));
+ fwrite(STDERR, print_r($result, true));
die(-1);
}
@@ -88,4 +86,3 @@ fwrite(STDERR, "Serializing this beast\n");
echo $calendar->serialize();
fwrite(STDERR, "done.\n");
-