Browse Source

Fix overflow error of seconds

master
Schneider 6 years ago
parent
commit
5ad61e9403
Signed by: schneider GPG Key ID: 3F50B02A50039F3B
  1. 8
      src/main.rs

8
src/main.rs

@ -14,7 +14,7 @@ fn main() {
/// ///
/// Default time settings are 25 minutes for a working block and 5 minutes for a break. /// Default time settings are 25 minutes for a working block and 5 minutes for a break.
fn run() -> Result<()> { fn run() -> Result<()> {
let work_duration = Duration::seconds(if cfg!(debug_assertions) { 5 } else { 25 * 60 });
let work_duration = Duration::seconds(if cfg!(debug_assertions) { 75 } else { 25 * 60 });
let break_duration = Duration::seconds(if cfg!(debug_assertions) { 5 } else { 5 * 60 }); let break_duration = Duration::seconds(if cfg!(debug_assertions) { 5 } else { 5 * 60 });
loop { loop {
@ -54,9 +54,9 @@ fn timer(name: &str, after_msg: &str, duration: &Duration) -> Result<()> {
} }
let elapsed_time: NaiveTime = NaiveTime::from_hms( let elapsed_time: NaiveTime = NaiveTime::from_hms(
elapsed.num_hours() as u32,
elapsed.num_minutes() as u32,
elapsed.num_seconds() as u32,
(elapsed.num_hours() % 24) as u32,
(elapsed.num_minutes() % 60) as u32,
(elapsed.num_seconds() % 60) as u32,
); );
write!(out, "Time elapsed: {}", elapsed_time.format(TIME_FORMAT))?; write!(out, "Time elapsed: {}", elapsed_time.format(TIME_FORMAT))?;
out.flush().unwrap(); out.flush().unwrap();

Loading…
Cancel
Save