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:
parent
48e27739f5
commit
d930323da9
1 changed files with 9 additions and 3 deletions
|
|
@ -210,9 +210,15 @@ impl Metadata {
|
|||
pub fn originally_created(&self) -> Option<String> {
|
||||
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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue