Skip to content

Commit

Permalink
for good measure, use unsigned_abs() for a variant that can't panic.
Browse files Browse the repository at this point in the history
Otherwise `N::MIN` can't be turned unto that same type abs version, but
it can fit into its unsiged version of the type.
  • Loading branch information
Byron committed Oct 26, 2023
1 parent 9b1a575 commit 045dd9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gix-date/src/time/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ impl Time {

const ZERO: &[u8; 1] = b"0";

const SECONDS_PER_HOUR: i32 = 60 * 60;
let offset = self.offset.abs();
const SECONDS_PER_HOUR: u32 = 60 * 60;
let offset = self.offset.unsigned_abs();
let hours = offset / SECONDS_PER_HOUR;
assert!(hours < 25, "offset is more than a day: {hours}");
let minutes = (offset - (hours * SECONDS_PER_HOUR)) / 60;
Expand Down

0 comments on commit 045dd9d

Please sign in to comment.