From bec4b04085fe2a08267d0f742a99582d8382a50f Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Thu, 20 Aug 2026 00:57:36 -0700 Subject: [PATCH] refactor: extract the duplicated timespan lookup in cycle.php Signed-off-by: Thomas Vincent --- cycle.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cycle.php b/cycle.php index 5e10a7a..639fae7 100644 --- a/cycle.php +++ b/cycle.php @@ -56,6 +56,15 @@ break; } +function cycle_get_timespan() { + $timespan = []; + $first_weekdayid = read_user_setting('first_weekdayid'); + + get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid); + + return $timespan; +} + function cycle_graphs() { global $graphs_ppage, $graph_cols, $graphs; global $page_refresh_interval, $graph_timespans; @@ -82,9 +91,7 @@ function cycle_graphs() { } // get the start and end times for the graph - $timespan = []; - $first_weekdayid = read_user_setting('first_weekdayid'); - get_timespan($timespan, time(), get_request_var('timespan'), $first_weekdayid); + $timespan = cycle_get_timespan(); $graph_tree = $tree_id; $html = ''; @@ -182,9 +189,7 @@ function cycle() { } // get the start and end times for the graph - $timespan = []; - $first_weekdayid = read_user_setting('first_weekdayid'); - get_timespan($timespan, time(), get_request_var('timespan') , $first_weekdayid); + $timespan = cycle_get_timespan(); $graph_tree = $tree_id; $html = '';