Commit dca1b251549658caf9190cbd03c3359cadf9543d
1 parent
b2e93d92
Exists in
master
and in
111 other branches
non standard time formats for TT upload
Showing
1 changed file
with
15 additions
and
12 deletions
Show diff stats
php/classes/TimeTableMgr.php
... | ... | @@ -162,25 +162,28 @@ class TimeTableMgr extends AmdaObjectMgr |
162 | 162 | $description="Uploaded Time Table".PHP_EOL; |
163 | 163 | |
164 | 164 | foreach ($lines as $line){ |
165 | - if ($line[0] == '#') $description=$description."\n".substr($line,1,-1); | |
165 | + if ($line[0] == '#') $description=$description.PHP_EOL.substr($line,1,-1); | |
166 | 166 | else { |
167 | 167 | $date = explode(' ',$line); |
168 | 168 | if (!strtotime(trim($date[0]))) { |
169 | - $description=$description."\n".$line; | |
169 | + $description=$description.PHP_EOL.$line; | |
170 | 170 | continue; |
171 | 171 | } |
172 | 172 | // check if it is ISO format |
173 | 173 | if (!isset($isIso)) $isIso = preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', trim($date[0])); |
174 | 174 | if (!$isIso) { |
175 | - $tempT = strtotime(trim($date[0])); | |
176 | - $startDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); | |
177 | - $tempT = strtotime(trim($date[1])); | |
178 | - $stopDate = date('Y-m-d',$tempT)."T".date('H:i:s',$tempT); | |
179 | - //TODO convert time into non standard formats | |
180 | - // $startDate = DateTime::createFromFormat($timeFormat, trim($date[0]); | |
181 | - // $start = $startDate->format('Y-m-d')."T".$startDate->format('H:i:s'); | |
182 | - // $stopDate = DateTime::createFromFormat($timeFormat, trim($date[1]); | |
183 | - // $stop = $stopDate->format('Y-m-d')."T".$stopDate->format('H:i:s'); | |
175 | + if (count($date) == 2) { | |
176 | + $tempStartT = strtotime(trim($date[0])); | |
177 | + $tempStopT = strtotime(trim($date[1])); | |
178 | + } | |
179 | + else { // y-m-d h:m:s for example | |
180 | + $tempStartT = strtotime($date[0]." ".$date[1]); | |
181 | + $tempStopT = strtotime($date[2]." ".$date[3]); | |
182 | + } | |
183 | + | |
184 | + $startDate = date('Y-m-d\TH:i:s',$tempStartT); | |
185 | + $stopDate = date('Y-m-d\TH:i:s',$tempStopT); | |
186 | + | |
184 | 187 | if (!$onlyDescription) |
185 | 188 | $attributesToReturn['intervals'][] = array('start' => $startDate, 'stop' => $stopDate); |
186 | 189 | } |
... | ... | @@ -193,7 +196,7 @@ class TimeTableMgr extends AmdaObjectMgr |
193 | 196 | |
194 | 197 | $attributesToReturn['description'] = $description; |
195 | 198 | $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); |
196 | - $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); | |
199 | + $attributesToReturn['created'] = date('Y-m-d\TH:i:s'); | |
197 | 200 | |
198 | 201 | return $attributesToReturn; |
199 | 202 | } |
... | ... |