From d4f3db618d2b59e8636a99b0af6de1841c07d073 Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Mon, 13 Apr 2015 19:36:45 +0000 Subject: [PATCH] Time Conditions: Convert time-of-day to minute-of-day values, due to inconsistent behavior for time-of-day. --- app/time_conditions/time_condition_edit.php | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index 96bb88a846..41064de791 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -255,6 +255,17 @@ require_once "resources/header.php"; $cond_start = $_REQUEST['value'][$group_id][$cond_num]['start']; $cond_stop = $_REQUEST['value'][$group_id][$cond_num]['stop']; + //convert time-of-day to minute-of-day (due to inconsistencies with time-of-day on some systems) + if ($cond_var == 'time-of-day') { + $cond_var = 'minute-of-day'; + $array_cond_start = explode(':', $cond_start); + $cond_start = ($array_cond_start[0] * 60) + $array_cond_start[1]; + if ($cond_stop != '') { + $array_cond_stop = explode(':', $cond_stop); + $cond_stop = ($array_cond_stop[0] * 60) + $array_cond_stop[1]; + } + } + $cond_value = $cond_start; if ($cond_stop != '') { $range_indicator = ($cond_var == 'date-time') ? '~' : '-'; @@ -851,6 +862,16 @@ if ($action == 'update') { $cond_val_start = $tmp[0]; $cond_val_stop = $tmp[1]; unset($tmp); + + //convert time-of-day to minute-of-day (due to inconsistencies with time-of-day on some systems) + if ($cond_var == 'minute-of-day') { + $cond_var = 'time-of-day'; + $cond_val_start = number_pad(floor($cond_val_start / 60),2).":".number_pad(fmod($cond_val_start, 60),2); + if ($cond_val_stop != '') { + $cond_val_stop = number_pad(floor($cond_val_stop / 60),2).":".number_pad(fmod($cond_val_stop, 60),2); + } + } + echo "