From 6ae33efccb847e3307c47d5ee535abe7b1ddffa7 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Fri, 4 Sep 2015 19:37:44 -0700 Subject: [PATCH] MDL-49561 core_lib: added info to bennu readme Also did some minor tweaks to existing code. --- calendar/export_execute.php | 4 ++-- lib/bennu/bennu.class.php | 25 ++++++++++++------------- lib/bennu/readme_moodle.txt | 1 + 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/calendar/export_execute.php b/calendar/export_execute.php index 2aa52fb508d..b999205db52 100644 --- a/calendar/export_execute.php +++ b/calendar/export_execute.php @@ -194,9 +194,9 @@ foreach($events as $event) { $ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); // when event starts. $ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration)); } else { - // When no duration is present, ie an all day event, VALUE should be date instead of time and dtend = dtstart + 1 day + // When no duration is present, ie an all day event, VALUE should be date instead of time and dtend = dtstart + 1 day. $ev->add_property('dtstart', Bennu::timestamp_to_date($event->timestart), array('value' => 'DATE')); // All day event. - $ev->add_property('dtend', Bennu::timestamp_to_date($event->timestart + 86400), array('value' => 'DATE')); // All day event. + $ev->add_property('dtend', Bennu::timestamp_to_date($event->timestart + DAYSECS), array('value' => 'DATE')); // All day event. } if ($event->courseid != 0) { $coursecontext = context_course::instance($event->courseid); diff --git a/lib/bennu/bennu.class.php b/lib/bennu/bennu.class.php index 4e6f09b032c..d5c7f414b54 100644 --- a/lib/bennu/bennu.class.php +++ b/lib/bennu/bennu.class.php @@ -8,7 +8,7 @@ * * See http://bennu.sourceforge.net/ for more information and downloads. * - * @author Ioannis Papaioannou + * @author Ioannis Papaioannou * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License */ @@ -21,44 +21,43 @@ class Bennu { } static function timestamp_to_date($t = NULL) { - if($t === NULL) { + if ($t === NULL) { $t = time(); } - return strftime('%Y%m%d', $t); + return gmstrftime('%Y%m%d', $t); } - static function generate_guid() { // Implemented as per the Network Working Group draft on UUIDs and GUIDs - + // These two octets get special treatment $time_hi_and_version = sprintf('%02x', (1 << 6) + mt_rand(0, 15)); // 0100 plus 4 random bits $clock_seq_hi_and_reserved = sprintf('%02x', (1 << 7) + mt_rand(0, 63)); // 10 plus 6 random bits - + // Need another 14 random octects $pool = ''; for($i = 0; $i < 7; ++$i) { $pool .= sprintf('%04x', mt_rand(0, 65535)); } - + // time_low = 4 octets $random = substr($pool, 0, 8).'-'; - + // time_mid = 2 octets $random .= substr($pool, 8, 4).'-'; - + // time_high_and_version = 2 octets $random .= $time_hi_and_version.substr($pool, 12, 2).'-'; - + // clock_seq_high_and_reserved = 1 octet $random .= $clock_seq_hi_and_reserved; - + // clock_seq_low = 1 octet $random .= substr($pool, 13, 2).'-'; - + // node = 6 octets $random .= substr($pool, 14, 12); - + return $random; } } diff --git a/lib/bennu/readme_moodle.txt b/lib/bennu/readme_moodle.txt index c27a1720e0b..e0b270acd3e 100644 --- a/lib/bennu/readme_moodle.txt +++ b/lib/bennu/readme_moodle.txt @@ -7,3 +7,4 @@ modifications: 4/ updated rfc2445_is_valid_value() to accept single part rrule as a valid value (16 Jun 2014) 5/ updated DTEND;TZID and DTSTAR;TZID values to support quotations (7 Nov 2014) 6/ added calendar_normalize_tz function to convert region timezone to php supported timezone (7 Nov 2014) +7/ added timestamp_to_date function to support zero duration events (4 Sept 2015) \ No newline at end of file