|
@@ 338-346 (lines=9) @@
|
| 335 |
|
// We are in hours and can add something |
| 336 |
|
$end_event->add(new \DateInterval('PT1H')); |
| 337 |
|
} |
| 338 |
|
elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
| 339 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 340 |
|
$normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
| 341 |
|
// Start event becomes the end event with a minute added |
| 342 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 343 |
|
// End event comes the current point in time |
| 344 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':00'); |
| 345 |
|
$current_value = $hour_value; |
| 346 |
|
} |
| 347 |
|
if ($current_value === NULL) { |
| 348 |
|
// Got into hours and still haven't created an event so |
| 349 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':00'); |
|
@@ 360-368 (lines=9) @@
|
| 357 |
|
// We are adding a whole day so the end event gets moved to the end of the day we are adding |
| 358 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 359 |
|
} |
| 360 |
|
elseif (($current_value !== $value) && ($current_value !== NULL)) { |
| 361 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 362 |
|
$normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
| 363 |
|
// Start event becomes the end event with a minute added |
| 364 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 365 |
|
// End event becomes the current day which we have not account for yet |
| 366 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 367 |
|
$current_value = $value; |
| 368 |
|
} |
| 369 |
|
if ($current_value === NULL) { |
| 370 |
|
// We have not created an event yet so let's do it now |
| 371 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '00:00'); |