Skip to content

Commit

Permalink
#75 make ONE_DAY a const
Browse files Browse the repository at this point in the history
  • Loading branch information
fsktom committed Sep 8, 2024
1 parent ad12c3c commit a2301a6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,19 @@ impl SongEntries {
&self,
time_span: TimeDelta,
) -> (TimeDelta, DateTime<Local>, DateTime<Local>) {
/// Duration of one day
const ONE_DAY: TimeDelta = TimeDelta::days(1);

let first = self.first_date();
let last = self.last_date();

let one_day = TimeDelta::days(1);

let actual_time_span = match time_span {
// maximum duration is whole dataset?
x if x >= last - first => {
return (gather::listening_time(self), first, last);
}
// minimum duration is 1 day
x if x < one_day => one_day,
x if x < ONE_DAY => ONE_DAY,
// duration is within bounds
_ => time_span,
};
Expand All @@ -406,8 +407,8 @@ impl SongEntries {
start_max = start;
end_max = end;
}
start += one_day;
end += one_day;
start += ONE_DAY;
end += ONE_DAY;
}
(highest, start_max, end_max)
}
Expand Down

0 comments on commit a2301a6

Please sign in to comment.