|
@@ 400-408 (lines=9) @@
|
| 397 |
|
// We are in hours and can add something |
| 398 |
|
$end_event->add(new \DateInterval('PT1H')); |
| 399 |
|
} |
| 400 |
|
elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
| 401 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 402 |
|
$normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 403 |
|
// Start event becomes the end event with a minute added |
| 404 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 405 |
|
// End event comes the current point in time |
| 406 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':00'); |
| 407 |
|
$current_value = $hour_value; |
| 408 |
|
} |
| 409 |
|
if ($current_value === NULL) { |
| 410 |
|
// Got into hours and still haven't created an event so |
| 411 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':00'); |
|
@@ 422-430 (lines=9) @@
|
| 419 |
|
// We are adding a whole day so the end event gets moved to the end of the day we are adding |
| 420 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 421 |
|
} |
| 422 |
|
elseif (($current_value !== $value) && ($current_value !== NULL)) { |
| 423 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 424 |
|
$normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 425 |
|
// Start event becomes the end event with a minute added |
| 426 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 427 |
|
// End event becomes the current day which we have not account for yet |
| 428 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 429 |
|
$current_value = $value; |
| 430 |
|
} |
| 431 |
|
if ($current_value === NULL) { |
| 432 |
|
// We have not created an event yet so let's do it now |
| 433 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '00:00'); |