aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/bin/generateicalendardata.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
committerfriendica <info@friendica.com>2013-10-21 15:46:31 -0700
commitb35122f7a6ad42756c35bb60ba1f06c3dcd45c77 (patch)
treeccdf373ce6475d264778523259cc32899b732fe7 /vendor/sabre/vobject/bin/generateicalendardata.php
parente3504df514d306cfe6b83e44a11f550664564af4 (diff)
downloadvolse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.gz
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.tar.bz2
volse-hubzilla-b35122f7a6ad42756c35bb60ba1f06c3dcd45c77.zip
add sabre (1.8.x) via composer in the !@#$ place it wants to be
Diffstat (limited to 'vendor/sabre/vobject/bin/generateicalendardata.php')
-rwxr-xr-xvendor/sabre/vobject/bin/generateicalendardata.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/vendor/sabre/vobject/bin/generateicalendardata.php b/vendor/sabre/vobject/bin/generateicalendardata.php
new file mode 100755
index 000000000..92c8c106d
--- /dev/null
+++ b/vendor/sabre/vobject/bin/generateicalendardata.php
@@ -0,0 +1,91 @@
+#!/usr/bin/env php
+<?php
+
+use Sabre\VObject;
+
+if ($argc<2) {
+ $cmd = $argv[0];
+ fwrite(STDERR, <<<HI
+Fruux test data generator
+
+This script generates a lot of test data. This is used for profiling and stuff.
+Currently it just generates events in a single calendar.
+
+The iCalendar output goes to stdout. Other messages to stderr.
+
+{$cmd} [events]
+
+
+HI
+ );
+ die();
+}
+
+$events = 100;
+
+if (isset($argv[1])) $events = (int)$argv[1];
+
+include __DIR__ . '/../vendor/autoload.php';
+
+fwrite(STDERR, "Generating " . $events . " events\n");
+
+$currentDate = new DateTime('-' . round($events/2) . ' days');
+
+$calendar = VObject\Component::create('VCALENDAR');
+$calendar->version = '2.0';
+$calendar->calscale = 'GREGORIAN';
+
+$ii=0;
+
+while($ii < $events) {
+
+ $ii++;
+
+ $event = VObject\Component::create('VEVENT');
+ $event->DTSTART = 'bla';
+ $event->SUMMARY = 'Event #' . $ii;
+ $event->UID = md5(microtime(true));
+
+ $doctorRandom = mt_rand(1,1000);
+
+ switch($doctorRandom) {
+ // All-day event
+ 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);
+ break;
+ case 2 :
+ $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';
+ break;
+
+ }
+
+ $calendar->add($event);
+ $currentDate->modify('+ ' . mt_rand(0,3) . ' days');
+
+}
+fwrite(STDERR, "Validating\n");
+
+$result = $calendar->validate();
+if ($result) {
+ fwrite(STDERR, "Errors!\n");
+ fwrite(STDERR, print_r($result,true));
+ die(-1);
+}
+
+fwrite(STDERR, "Serializing this beast\n");
+
+echo $calendar->serialize();
+
+fwrite(STDERR, "done.\n");
+