Skip to content

Commit

Permalink
Prevent FridgeTag (cumulative) breaches going past midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianwb committed Dec 12, 2023
1 parent 4b0c116 commit 5764b9b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/berlinger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,18 @@ fn parse_fridgetag_breach(
}

if valid_breach {

let breach_start_timestamp = NaiveDateTime::new(breach_date, start_time);
let mut breach_end_timestamp = breach_start_timestamp + breach_duration; // only true for consecutive breaches, but this is all the data we have for FridgeTags

if breach_end_timestamp.date() > breach_date { // FridgeTag breach can't go into next day
breach_end_timestamp = NaiveDateTime::new(breach_date, zero_time) + Duration::days(1);
}

let temperature_breach = TemperatureBreach {
breach_type: breach_type,
start_timestamp: breach_start_timestamp,
end_timestamp: breach_start_timestamp + breach_duration, // only true for consecutive breaches, but this is all the data we have for FridgeTags
end_timestamp: breach_end_timestamp,
duration: breach_duration,
acknowledged: false,
};
Expand Down

0 comments on commit 5764b9b

Please sign in to comment.