handle events started before 1900 (closes: #58)

DTSTART/DTEND can be DATE values instead of DATE-TIME. Our database uses
TIMESTAMP WITH TIME ZONE as field type, which seems to accept 19011224
but not values before 1900, such as 18961224. This patch changes values
between 1000 and 1900 to DATE-TIME by adding "T000000Z"

Patch contributed by Benedikt Spranger <b.spranger@linutronix.de>

Patch limited to dates between 1000 and 1900 by Florian Schlichting
<fsfs@debian.org>
This commit is contained in:
Benedikt Spranger 2014-10-12 09:38:17 +02:00 committed by Florian Schlichting
parent bf733fca8e
commit c35704cc4b

View File

@ -1262,12 +1262,16 @@ function write_resource( DAVResource $resource, $caldav_data, DAVResource $colle
if ( $first->GetType() == 'VTODO' ) $due = $first->GetPValue('DUE');
$calitem_params[':due'] = $due;
$dtstart = $first->GetPValue('DTSTART');
if ( empty($dtstart) ) $dtstart = $due;
if ( empty($dtstart) ) $dtstart = $due;
if (preg_match("/^1[0-8][0-9][0-9][01][0-9][0-3][0-9]$/", $dtstart))
$dtstart = $dtstart . "T000000Z";
$calitem_params[':dtstart'] = $dtstart;
$dtend = $first->GetPValue('DTEND');
if ( isset($dtend) && $dtend != '' ) {
dbg_error_log( 'PUT', ' DTEND: "%s", DTSTART: "%s", DURATION: "%s"', $dtend, $dtstart, $first->GetPValue('DURATION') );
if (preg_match("/^1[0-8][0-9][0-9][01][0-9][0-3][0-9]$/", $dtend))
$dtend = $dtend . "T000000Z";
$calitem_params[':dtend'] = $dtend;
$dtend = ':dtend';
}