aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-07-28 21:55:28 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-07-28 21:55:28 -0700
commit4c83e9b6b49061cbd87ddb5e09976625e43c8394 (patch)
tree66f5f40d74d9347823f80d6bf59960ca407b6432 /include
parent03756c65fc1c5bebfc4009bca32b5f681b5c1b21 (diff)
downloadvolse-hubzilla-4c83e9b6b49061cbd87ddb5e09976625e43c8394.tar.gz
volse-hubzilla-4c83e9b6b49061cbd87ddb5e09976625e43c8394.tar.bz2
volse-hubzilla-4c83e9b6b49061cbd87ddb5e09976625e43c8394.zip
initial work on using sabre as a vcalendar parser
Diffstat (limited to 'include')
-rw-r--r--include/event.php51
1 files changed, 50 insertions, 1 deletions
diff --git a/include/event.php b/include/event.php
index 784da0545..af828495b 100644
--- a/include/event.php
+++ b/include/event.php
@@ -1,4 +1,6 @@
<?php
+use Sabre\VObject;
+
/**
* @file include/event.php
*/
@@ -371,7 +373,32 @@ function event_addtocal($item_id, $uid) {
function parse_ical_file($f,$uid) {
- require_once('library/ical.php');
+require_once('vendor/autoload.php');
+
+ $s = @file_get_contents($f);
+
+ // Change the current timezone to something besides UTC.
+ // Doesn't matter what it is, as long as it isn't UTC.
+ // Save the current timezone so we can reset it when we're done processing.
+
+ $saved_timezone = date_default_timezone_get();
+ date_default_timezone_set('Australia/Sydney');
+
+ $ical = VObject\Reader::read($s);
+
+ if($ical) {
+ foreach($ical->VEVENT as $event) {
+ event_import_ical($event,$uid);
+
+ }
+ }
+
+ date_default_timezone_set($saved_timezone);
+
+ logger('vobject: ' . print_r($ical,true));
+ return true;
+
+// require_once('library/ical.php');
$ical = new ICal($f);
if($ical) {
$events = $ical->events();
@@ -400,6 +427,28 @@ function event_import_ical($ical, $uid) {
$channel = $c[0];
$ev = array();
+
+
+
+ $dtstart = $event->DTSTART->getDateTime();
+ if(($dtstart['timezone_type'] == 2) || (($dtstart['timezone_type'] == 3) && ($dtstart['timezone'] === 'UTC'))) {
+ $ev['adjust'] = 1;
+ }
+ else {
+ $ev['adjust'] = 0;
+ }
+
+ $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
+ $dtstart->format(\DateTime::W3C));
+
+
+
+// logger('event: ' . print_r($event->DTSTART->getDateTime(),true));
+
+
+
+
+
if($ical['CREATED'])
$ev['created'] = datetime_convert('UTC','UTC',$ical['CREATED']);
if($ical['LAST-MODIFIED'])