changed Day implementation

This commit is contained in:
2025-10-10 01:12:46 +02:00
parent 030a372949
commit f1b471c6d8
7 changed files with 85 additions and 47 deletions

View File

@@ -9,7 +9,7 @@ use esp_hal::{
};
use log::{debug, error, info};
use crate::{FEEDBACK_STATE, drivers, feedback, store::Date};
use crate::{FEEDBACK_STATE, drivers, feedback};
include!(concat!(env!("OUT_DIR"), "/build_time.rs"));
@@ -45,31 +45,6 @@ impl RTCClock {
}
}
}
pub async fn get_date(&mut self) -> Date {
let (year, month, day) = unix_to_ymd_string(self.get_time().await);
let mut buffer: Date = [0; 10];
// Write YYYY
buffer[0] = b'0' + ((year / 1000) % 10) as u8;
buffer[1] = b'0' + ((year / 100) % 10) as u8;
buffer[2] = b'0' + ((year / 10) % 10) as u8;
buffer[3] = b'0' + (year % 10) as u8;
buffer[4] = b'.';
// Write MM
buffer[5] = b'0' + (month / 10) as u8;
buffer[6] = b'0' + (month % 10) as u8;
buffer[7] = b'.';
// Write DD
buffer[8] = b'0' + (day / 10) as u8;
buffer[9] = b'0' + (day % 10) as u8;
buffer
}
}
fn unix_to_ymd_string(timestamp: u64) -> (u16, u8, u8) {