From d930323da979047274c3fbb5f9fb7eaa837d3f85 Mon Sep 17 00:00:00 2001 From: Alexandros Kosiaris Date: Wed, 10 Sep 2025 15:56:19 +0300 Subject: [PATCH] Don't force UTC on naive datetime structs Why: When a camera ships EXIF information that lacks any type of offset and/or timezone information, any kind of information that would help make a decision regarding the timezone is absent. Forcing UTC means that most users of such cameras will end up with datetimes reported that have nothing to do with the ones they expect. The only assumption that holds some water, is to assume that the picture was taken in the same timezone as the device running Loupe and hope that's true. If it is not, it is undetectable programmatically, and the user will have to mentally compensate for it What: Switch from using from_unix_local() and parsing the timestamp of the naive datetime as UTC to using from_local() and passing the arguments needed --- src/metadata.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/metadata.rs b/src/metadata.rs index bc79a11..8ca00bf 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -210,9 +210,15 @@ impl Metadata { pub fn originally_created(&self) -> Option { if let Some(date_time) = &self.metadata.date_time_original() { let glib_date_time = match date_time { - DateTime::Naive(naive) => { - glib::DateTime::from_unix_local(naive.and_utc().timestamp()).ok() - } + DateTime::Naive(naive) => glib::DateTime::from_local( + naive.year(), + naive.month() as i32, + naive.day() as i32, + naive.hour() as i32, + naive.minute() as i32, + naive.second() as f64, + ) + .ok(), DateTime::FixedOffset(fixed) => { let naive = fixed.naive_utc(); glib::DateTime::new(