From ba59b62b2bcde70a8771e7bce5459628434a887a Mon Sep 17 00:00:00 2001 From: alemidev Date: Sun, 12 Jun 2022 12:00:25 +0200 Subject: [PATCH] fix: vertical lines align with local days used to align to UTC days, which looked quite off --- src/app/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index 34875da..4150549 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -3,7 +3,7 @@ pub mod worker; pub mod util; use std::sync::Arc; -use chrono::Utc; +use chrono::{Utc, Local}; use eframe::egui; use eframe::egui::plot::GridMark; use eframe::egui::{RichText, plot::{Line, Plot}, Color32}; @@ -215,13 +215,14 @@ impl eframe::App for App { } }); p = p.x_grid_spacer(|grid| { + let offset = Local::now().offset().local_minus_utc() as i64; let (start, end) = grid.bounds; let mut counter = (start as i64) - ((start as i64) % 3600); let mut out : Vec = Vec::new(); loop { counter += 3600; if counter > end as i64 { break; } - if counter % 86400 == 0 { + if (counter + offset) % 86400 == 0 { out.push(GridMark { value: counter as f64, step_size: 86400 as f64 }) } else if counter % 3600 == 0 { out.push(GridMark { value: counter as f64, step_size: 3600 as f64 });