Skip to content

Commit

Permalink
Fix clock API (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc authored Nov 2, 2024
1 parent e6f8911 commit cb33594
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/api/clock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::api::fs;
use core::convert::TryInto;
use alloc::string::String;

pub const DATE_TIME_ZONE: &str = "%Y-%m-%d %H:%M:%S %z";
pub const DATE_TIME: &str = "%Y-%m-%d %H:%M:%S";
Expand All @@ -11,8 +11,10 @@ pub const DATE_LEN: usize = 10;

fn read_float(path: &str) -> f64 {
if let Ok(bytes) = fs::read_to_bytes(path) {
if bytes.len() == 8 {
return f64::from_be_bytes(bytes[0..8].try_into().unwrap());
if let Ok(s) = String::from_utf8(bytes) {
if let Ok(n) = s.parse() {
return n;
}
}
}
0.0
Expand Down

0 comments on commit cb33594

Please sign in to comment.