Skip to content

Commit c215715

Browse files
author
Rehan Rana
committed
Fixed bugs relating to sun sync
1 parent 8a3fe79 commit c215715

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ pub fn sun_timings(
507507
let (sunset, sunrise) = (sunset.with_timezone(&Local), sunrise.with_timezone(&Local));
508508
let sunset = Time::new((sunset.hour() * 60) + sunset.minute());
509509
let sunrise = Time::new((sunrise.hour() * 60) + sunrise.minute());
510-
let step_time_day = Time::new((sunset.total_mins - sunrise.total_mins) / (dir_count_day - 1));
510+
let step_time_day = Time::new((sunset.total_mins - sunrise.total_mins) / (dir_count_day));
511511
let step_time_night =
512512
Time::new((1440 - (sunset.total_mins - sunrise.total_mins)) / dir_count_night);
513513
let mut loop_time_night: Time;
@@ -521,7 +521,8 @@ pub fn sun_timings(
521521
}
522522
loop_time_day += step_time_day;
523523
}
524-
loop_time_night = sunset.to_owned() + step_time_night;
524+
times.pop();
525+
loop_time_night = sunset.to_owned();
525526

526527
while loop_time_night < (sunrise + FULL_DAY) {
527528
if loop_time_night >= FULL_DAY {

0 commit comments

Comments
 (0)