From 719912f453c487031eecccc6ff8521645f9ef001 Mon Sep 17 00:00:00 2001 From: jacobbuscher-bt <111894981+jacobbuscher-bt@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:24:14 -0600 Subject: [PATCH] Fix time conditions using 'minute-of-day' switching 1 minute early (#6784) Fix time conditions using 'minute-of-day' switching 1 minute early. We are augmenting the value saved based on what select option is selected. 12:00 AM - 11:59 PM will now serialize as 1-1439 as expected 11:59 PM - 11:59 PM will now serialize as 1440-1439 which is unexpected behavior due to freeswitch's 'wrap around' behavior but acceptable. Additional information minute-of-day 1-1440 minute of the day (midnight = 1, 1am = 60, noon = 720, etc) --- app/time_conditions/time_condition_edit.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/time_conditions/time_condition_edit.php b/app/time_conditions/time_condition_edit.php index 11a89d786a..2b8f3435c4 100644 --- a/app/time_conditions/time_condition_edit.php +++ b/app/time_conditions/time_condition_edit.php @@ -318,7 +318,8 @@ 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]; + //adjust time one minute later to account for freeswitch one minute early on start condition behavior. + $cond_start = ($array_cond_start[0] * 60) + $array_cond_start[1] + 1; if ($cond_stop != '') { $array_cond_stop = explode(':', $cond_stop); $cond_stop = ($array_cond_stop[0] * 60) + $array_cond_stop[1]; @@ -1034,6 +1035,10 @@ if ($action == 'update') { //convert minute-of-day to time-of-day values if ($cond_var == 'minute-of-day') { $cond_var = 'time-of-day'; + + //adjust time one minute earlier to account for freeswitch one minute early on start condition behavior. + $cond_val_start = $cond_val_start - 1; + $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); @@ -1308,4 +1313,4 @@ if ($action == 'update') { //include the footer require_once "resources/footer.php"; -?> \ No newline at end of file +?>