|
@@ -123,7 +123,7 @@ discard block |
|
|
block discarded – undo |
|
123
|
123
|
$current_states = array_keys($unit_states); |
|
124
|
124
|
// Compare the current states with the set of valid states |
|
125
|
125
|
$remaining_states = array_diff($current_states, $valid_states); |
|
126
|
|
- if (count($remaining_states) == 0 ) { |
|
|
126
|
+ if (count($remaining_states) == 0) { |
|
127
|
127
|
// Unit is in a state that is within the set of valid states so add to result set |
|
128
|
128
|
$units[$unit] = $unit; |
|
129
|
129
|
$response->addMatch($keyed_units[$unit], CalendarResponse::VALID_STATE); |
|
@@ -212,7 +212,7 @@ discard block |
|
|
block discarded – undo |
|
212
|
212
|
foreach ($months as $month => $days) { |
|
213
|
213
|
foreach ($days as $day => $hours) { |
|
214
|
214
|
foreach ($hours as $hour => $value) { |
|
215
|
|
- $events[$unit][Event::BAT_HOUR][$year][$month]['d'.$day][$hour] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
|
215
|
+ $events[$unit][Event::BAT_HOUR][$year][$month]['d' . $day][$hour] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
216
|
216
|
} |
|
217
|
217
|
} |
|
218
|
218
|
} |
|
@@ -226,7 +226,7 @@ discard block |
|
|
block discarded – undo |
|
226
|
226
|
foreach ($hours as $hour => $minutes) { |
|
227
|
227
|
foreach ($minutes as $minute => $value) { |
|
228
|
228
|
if (isset($db_events[$unit][Event::BAT_MINUTE][$year][$month][$day][$hour][$minute])) { |
|
229
|
|
- $events[$unit][Event::BAT_MINUTE][$year][$month]['d' .$day]['h'.$hour][$minute] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute]); |
|
|
229
|
+ $events[$unit][Event::BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour][$minute] = ((int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute] == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$db_events[$unit][BAT_DAY][$year][$month][$day][$hour][$minute]); |
|
230
|
230
|
} |
|
231
|
231
|
else { |
|
232
|
232
|
// If nothing from db - then revert to the defaults |
|
@@ -244,7 +244,7 @@ discard block |
|
|
block discarded – undo |
|
244
|
244
|
foreach ($days as $day => $hours) { |
|
245
|
245
|
foreach ($hours as $hour => $minutes) { |
|
246
|
246
|
foreach ($minutes as $minute => $value) { |
|
247
|
|
- $events[$unit][Event::BAT_MINUTE][$year][$month]['d'.$day]['h'.$hour][$minute] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
|
247
|
+ $events[$unit][Event::BAT_MINUTE][$year][$month]['d' . $day]['h' . $hour][$minute] = ((int)$value == 0 ? $keyed_units[$unit]->getDefaultValue() : (int)$value); |
|
248
|
248
|
} |
|
249
|
249
|
} |
|
250
|
250
|
} |
|
@@ -316,12 +316,12 @@ discard block |
|
|
block discarded – undo |
|
316
|
316
|
// Value just switched - let us wrap up with current event and start a new one |
|
317
|
317
|
$normalized_events[$unit][] = new Event($start_event, $end_event, $unit, $current_value); |
|
318
|
318
|
$start_event = clone($end_event->add(new \DateInterval('PT1M'))); |
|
319
|
|
- $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
|
319
|
+ $end_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute, 1)); |
|
320
|
320
|
$current_value = $minute_value; |
|
321
|
321
|
} |
|
322
|
322
|
if ($current_value === NULL) { |
|
323
|
323
|
// We are down to minutes and haven't created and event yet - do one now |
|
324
|
|
- $start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute,1)); |
|
|
324
|
+ $start_event = new \DateTime($year . '-' . $month . '-' . substr($day, 1) . ' ' . substr($hour, 1) . ':' . substr($minute, 1)); |
|
325
|
325
|
$end_event = clone($start_event); |
|
326
|
326
|
} |
|
327
|
327
|
$current_value = $minute_value; |