changes
This commit is contained in:
@@ -23,7 +23,7 @@ use std::ffi::CString;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::{DateTime, NaiveDateTime, Utc};
|
||||
use chrono::{DateTime, Utc};
|
||||
use ds18b20::Ds18b20;
|
||||
use std::result::Result::Ok as OkStd;
|
||||
use std::str::FromStr;
|
||||
@@ -277,8 +277,7 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
|
||||
|
||||
fn last_pump_time(&self, plant: usize) -> chrono::DateTime<Utc> {
|
||||
let ts = unsafe { LAST_WATERING_TIMESTAMP }[plant];
|
||||
let timestamp = NaiveDateTime::from_timestamp_millis(ts).unwrap();
|
||||
DateTime::<Utc>::from_naive_utc_and_offset(timestamp, Utc)
|
||||
return DateTime::from_timestamp_millis(ts).unwrap();
|
||||
}
|
||||
|
||||
fn store_last_pump_time(&mut self, plant: usize, time: chrono::DateTime<Utc>) {
|
||||
@@ -322,9 +321,9 @@ impl PlantCtrlBoardInteraction for PlantCtrlBoard<'_> {
|
||||
fn time(&mut self) -> Result<chrono::DateTime<Utc>> {
|
||||
let time = EspSystemTime {}.now().as_millis();
|
||||
let smaller_time = time as i64;
|
||||
let local_time = NaiveDateTime::from_timestamp_millis(smaller_time)
|
||||
let local_time = DateTime::from_timestamp_millis(smaller_time)
|
||||
.ok_or(anyhow!("could not convert timestamp"))?;
|
||||
Ok(local_time.and_utc())
|
||||
Ok(local_time)
|
||||
}
|
||||
|
||||
fn sntp(&mut self, max_wait_ms: u32) -> Result<chrono::DateTime<Utc>> {
|
||||
@@ -920,9 +919,8 @@ impl CreatePlantHal<'_> for PlantHal {
|
||||
);
|
||||
for i in 0..PLANT_COUNT {
|
||||
let smaller_time = LAST_WATERING_TIMESTAMP[i];
|
||||
let local_time = NaiveDateTime::from_timestamp_millis(smaller_time)
|
||||
let utc_time = DateTime::from_timestamp_millis(smaller_time)
|
||||
.ok_or(anyhow!("could not convert timestamp"))?;
|
||||
let utc_time = local_time.and_utc();
|
||||
let europe_time = utc_time.with_timezone(&Berlin);
|
||||
|
||||
println!(
|
||||
|
||||
Reference in New Issue
Block a user