From 9000337eba6d98fdfdf462abf1b488779d19a3a5 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Mon, 25 May 2026 08:13:42 -0400 Subject: [PATCH] Fixed runtime_thermostat_summary->read not supporting date ranges --- api/runtime_thermostat_summary.php | 53 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/api/runtime_thermostat_summary.php b/api/runtime_thermostat_summary.php index 1afeed9..1e148ff 100755 --- a/api/runtime_thermostat_summary.php +++ b/api/runtime_thermostat_summary.php @@ -61,21 +61,32 @@ class runtime_thermostat_summary extends cora\crud { $base = strtotime('+' . $date_time->getOffset() . ' seconds'); } - // If a date was given, apply the base time adjustment to correct for time - // zones. - if(isset($attributes['date']) === true) { - if(is_array($attributes['date']) === true) { - $attributes['date']['value'] = date( - 'Y-m-d', - strtotime($attributes['date']['value'], $base) - ); - } else { - $attributes['date'] = date( - 'Y-m-d', - strtotime($attributes['date'], $base) - ); - } - } + // If a date was given, apply the base time adjustment to correct for time + // zones. + if(isset($attributes['date']) === true) { + if(is_array($attributes['date']) === true) { + if(is_array($attributes['date']['value']) === true) { + $attributes['date']['value'][0] = date( + 'Y-m-d', + strtotime($attributes['date']['value'][0], $base) + ); + $attributes['date']['value'][1] = date( + 'Y-m-d', + strtotime($attributes['date']['value'][1], $base) + ); + } else { + $attributes['date']['value'] = date( + 'Y-m-d', + strtotime($attributes['date']['value'], $base) + ); + } + } else { + $attributes['date'] = date( + 'Y-m-d', + strtotime($attributes['date'], $base) + ); + } + } $runtime_thermostat_summaries = array_merge( $runtime_thermostat_summaries, @@ -91,12 +102,12 @@ class runtime_thermostat_summary extends cora\crud { $runtime_thermostat_summary['sum_heating_degree_days'] /= 10; $runtime_thermostat_summary['sum_cooling_degree_days'] /= 10; } - - return $runtime_thermostat_summaries; - } - - /** - * Populate from the max populated date until now. + + return $runtime_thermostat_summaries; + } + + /** + * Populate from the max populated date until now. * * @param int $thermostat_id */