From eb99194e16aaed99949929008fae85ae21af2578 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 23 May 2022 17:48:45 +0200 Subject: [PATCH] [Refactor] Remove the time_to_degrees function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It just passed its sole parameter to seconds_to_degrees, so having this function doesn’t really make sense. It was actually a remnant from the Python version which operated on timestamps, not raw seconds-since-midnight values. --- src/main.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8b4acf4..96cd372 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,14 +40,9 @@ fn seconds_to_degrees(seconds: i32) -> f32 { seconds as f32 * 360.0 / 86400.0 } -fn time_to_degrees(timestamp: i32, // should be time/timestamp -) -> f32 { - seconds_to_degrees(timestamp) -} - fn get_range_path(radius: f32, range_name: &str, start_time: i32, end_time: i32) -> Path { - let start_deg = time_to_degrees(start_time); - let end_deg = time_to_degrees(end_time); + let start_deg = seconds_to_degrees(start_time); + let end_deg = seconds_to_degrees(end_time); let deg_diff = end_deg - start_deg; let start_delta_x = radius * start_deg.to_radians().sin(); @@ -275,7 +270,7 @@ fn gen_svg(config: &Option, hour_name_path_cache: &[(PathData, PathData) "transform", format!( "rotate({}, {}, {})", - time_to_degrees(local_time) - utc_rotation, + seconds_to_degrees(local_time) - utc_rotation, IMAGE_WIDTH / 2, IMAGE_WIDTH / 2 ), @@ -302,7 +297,7 @@ fn gen_svg(config: &Option, hour_name_path_cache: &[(PathData, PathData) "transform", format!( "rotate({}, {}, {})", - time_to_degrees(noon), + seconds_to_degrees(noon), IMAGE_WIDTH / 2, IMAGE_WIDTH / 2 ), @@ -321,7 +316,7 @@ fn gen_svg(config: &Option, hour_name_path_cache: &[(PathData, PathData) "transform", format!( "rotate({}, {}, {})", - time_to_degrees(midnight), + seconds_to_degrees(midnight), IMAGE_WIDTH / 2, IMAGE_WIDTH / 2 ), @@ -377,7 +372,7 @@ fn gen_svg(config: &Option, hour_name_path_cache: &[(PathData, PathData) "transform", format!( "rotate({}, {}, {})", - time_to_degrees(local_time), + seconds_to_degrees(local_time), IMAGE_WIDTH / 2, IMAGE_WIDTH / 2 ),