Skip to content

Commit

Permalink
Fix rounding for Wh in sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Jun 8, 2024
1 parent 8ac4252 commit e3e9999
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,9 @@ pub fn convert_power(watts: f64) -> String {
}

pub fn convert_energy(watthours: f64, integer: bool) -> String {
let (number, prefix) = to_largest_prefix(watthours, Base::Decimal);
let (mut number, prefix) = to_largest_prefix(watthours, Base::Decimal);
if integer {
number = number.round();
match prefix {
Prefix::None => i18n_f("{} Wh", &[&number.to_string()]),
Prefix::Kilo => i18n_f("{} kWh", &[&number.to_string()]),
Expand Down

0 comments on commit e3e9999

Please sign in to comment.