diff --git a/php/classes/TimeTableMgr.php b/php/classes/TimeTableMgr.php index 8c88ffd..edd62f4 100644 --- a/php/classes/TimeTableMgr.php +++ b/php/classes/TimeTableMgr.php @@ -162,25 +162,28 @@ class TimeTableMgr extends AmdaObjectMgr $description="Uploaded Time Table".PHP_EOL; foreach ($lines as $line){ - if ($line[0] == '#') $description=$description."\n".substr($line,1,-1); + if ($line[0] == '#') $description=$description.PHP_EOL.substr($line,1,-1); else { $date = explode(' ',$line); if (!strtotime(trim($date[0]))) { - $description=$description."\n".$line; + $description=$description.PHP_EOL.$line; continue; } // check if it is ISO format if (!isset($isIso)) $isIso = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', trim($date[0])); if (!$isIso) { - $tempT = strtotime(trim($date[0])); - $startDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); - $tempT = strtotime(trim($date[1])); - $stopDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); - //TODO convert time into non standard formats - // $startDate = DateTime::createFromFormat($timeFormat, trim($date[0]); - // $start = $startDate->format('Y-m-d')."T".$startDate->format('H:i:s'); - // $stopDate = DateTime::createFromFormat($timeFormat, trim($date[1]); - // $stop = $stopDate->format('Y-m-d')."T".$stopDate->format('H:i:s'); + if (count($date) == 2) { + $tempStartT = strtotime(trim($date[0])); + $tempStopT = strtotime(trim($date[1])); + } + else { // y-m-d h:m:s for example + $tempStartT = strtotime($date[0]." ".$date[1]); + $tempStopT = strtotime($date[2]." ".$date[3]); + } + + $startDate = date('Y-m-d\TH:i:s',$tempStartT); + $stopDate = date('Y-m-d\TH:i:s',$tempStopT); + if (!$onlyDescription) $attributesToReturn['intervals'][] = array('start' => $startDate, 'stop' => $stopDate); } @@ -193,7 +196,7 @@ class TimeTableMgr extends AmdaObjectMgr $attributesToReturn['description'] = $description; $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); - $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); + $attributesToReturn['created'] = date('Y-m-d\TH:i:s'); return $attributesToReturn; } -- libgit2 0.21.2