From 2fec6b85ec06c9f3cb87633f8e356c89371d0c35 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Fri, 6 Dec 2013 13:55:10 -0500 Subject: [PATCH] Bug: 12869 Fix importing RRULE UNTIL values when they contain date parts. We were already treating UNTIL as inclusive as well as comparing them by datetime (as opposed to date). The problem was we weren't importing the time portion of the UNTIL value if it was present. --- framework/Date/lib/Horde/Date/Recurrence.php | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/framework/Date/lib/Horde/Date/Recurrence.php b/framework/Date/lib/Horde/Date/Recurrence.php index cfd8306860d..aabcc1a2d81 100644 --- a/framework/Date/lib/Horde/Date/Recurrence.php +++ b/framework/Date/lib/Horde/Date/Recurrence.php @@ -1123,13 +1123,23 @@ public function fromRRule20($rrule) break; } + // MUST take into account the time portion if it is present. + // See Bug: 12869 and Bug: 2813 if (isset($rdata['UNTIL'])) { - list($year, $month, $mday) = sscanf($rdata['UNTIL'], - '%04d%02d%02d'); - $this->setRecurEnd(new Horde_Date(array('year' => $year, - 'month' => $month, - 'mday' => $mday), - $this->start->timezone)); + if (preg_match('/^(\d{4})-?(\d{2})-?(\d{2})T? ?(\d{2}):?(\d{2}):?(\d{2})(?:\.\d+)?(Z?)$/', $rdata['UNTIL'], $parts)) { + $until = new Horde_Date($rdata['UNTIL'], 'UTC'); + $until->setTimezone($this->start->timezone); + } else { + list($year, $month, $mday) = sscanf($rdata['UNTIL'], + '%04d%02d%02d'); + $until = new Horde_Date( + array('year' => $year, + 'month' => $month, + 'mday' => $mday), + $this->start->timezone + ); + } + $this->setRecurEnd($until); } if (isset($rdata['COUNT'])) { $this->setRecurCount($rdata['COUNT']);