|
@@ 395-401 (lines=7) @@
|
| 392 |
|
// We are still in minutes and going through so add a minute |
| 393 |
|
$end_event->add(new \DateInterval('PT1M')); |
| 394 |
|
} |
| 395 |
|
elseif (($current_value != $minute_value) && ($current_value !== NULL)) { |
| 396 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 397 |
|
$normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 398 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 399 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
| 400 |
|
$current_value = $minute_value; |
| 401 |
|
} |
| 402 |
|
if ($current_value === NULL) { |
| 403 |
|
// We are down to minutes and haven't created and event yet - do one now |
| 404 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
@@ 414-422 (lines=9) @@
|
| 411 |
|
// We are in hours and can add something |
| 412 |
|
$end_event->add(new \DateInterval('PT1H')); |
| 413 |
|
} |
| 414 |
|
elseif (($current_value != $hour_value) && ($current_value !== NULL)) { |
| 415 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 416 |
|
$normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 417 |
|
// Start event becomes the end event with a minute added |
| 418 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 419 |
|
// End event comes the current point in time |
| 420 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':59'); |
| 421 |
|
$current_value = $hour_value; |
| 422 |
|
} |
| 423 |
|
if ($current_value === NULL) { |
| 424 |
|
// Got into hours and still haven't created an event so |
| 425 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':00'); |
|
@@ 436-444 (lines=9) @@
|
| 433 |
|
// We are adding a whole day so the end event gets moved to the end of the day we are adding |
| 434 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 435 |
|
} |
| 436 |
|
elseif (($current_value !== $value) && ($current_value !== NULL)) { |
| 437 |
|
// Value just switched - let us wrap up with current event and start a new one |
| 438 |
|
$normalized_events[$unit_id][] = new Event($start_event, $end_event, $this->getUnit($unit_id), $current_value); |
| 439 |
|
// Start event becomes the end event with a minute added |
| 440 |
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
| 441 |
|
// End event becomes the current day which we have not account for yet |
| 442 |
|
$end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '23:59'); |
| 443 |
|
$current_value = $value; |
| 444 |
|
} |
| 445 |
|
if ($current_value === NULL) { |
| 446 |
|
// We have not created an event yet so let's do it now |
| 447 |
|
$start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . '00:00'); |