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
This commit is contained in:
Alexandros Kosiaris 2025-09-10 15:56:19 +03:00 • committed by Sophie Herold
parent 48e27739f5
commit d930323da9

View file

@ -210,9 +210,15 @@ impl Metadata {
pub fn originally_created(&self) -> Option<String> { pub fn originally_created(&self) -> Option<String> {
if let Some(date_time) = &self.metadata.date_time_original() { if let Some(date_time) = &self.metadata.date_time_original() {
let glib_date_time = match date_time { let glib_date_time = match date_time {
DateTime::Naive(naive) => { DateTime::Naive(naive) => glib::DateTime::from_local(
glib::DateTime::from_unix_local(naive.and_utc().timestamp()).ok() 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) => { DateTime::FixedOffset(fixed) => {
let naive = fixed.naive_utc(); let naive = fixed.naive_utc();
glib::DateTime::new( glib::DateTime::new(