Gallery icon indicating copy to clipboard operation
Gallery copied to clipboard

"Fix Date Taken value" ignores OffsetTimeOriginal

Open MarkBirkholz opened this issue 4 weeks ago • 1 comments

Checklist

  • [x] I can reproduce the bug with the latest version given here.
  • [x] I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • [x] I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • [x] I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • [x] I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise.
  • [x] This issue contains only one bug.
  • [x] I have read and understood the contribution guidelines.

Affected app version

1.14.1

Affected Android/Custom ROM version

Android 17

Affected device model

Pixel 7

How did you install the app?

Google Play Store

Steps to reproduce the bug

  1. Take a photo with DateTimeOriginal and OffsetTimeOriginal set, in a time zone different from the device's current one.
  2. Select it, More options > Fix Date Taken value.
  3. Sort by date taken together with videos or photos from the same time.

Expected behavior

If OffsetTimeOriginal is present, date taken is DateTimeOriginal in that offset, the same value MediaProvider stores in DATE_TAKEN.

Actual behavior

fixDateTaken() parses DateTimeOriginal in the device time zone and ignores the offset. The photo is shifted by the difference between the two zones and the wrong value is saved to date_takens, overriding MediaStore.

Screenshots/Screen recordings

No response

Additional information

Possible fix: read TAG_OFFSET_TIME_ORIGINAL (TAG_OFFSET_TIME when falling back to TAG_DATETIME) and set it as the formatter time zone when present. Files without an offset keep the current behavior.

MarkBirkholz avatar Nov 05 '26 23:11 MarkBirkholz

One trap for the proposed formatter fix: an EXIF offset such as +02:00 is not a valid standalone ID for java.util.TimeZone.getTimeZone(String). In a local JVM probe:

TimeZone.getTimeZone("+02:00")     -> GMT, offset 0
TimeZone.getTimeZone("GMT+02:00")  -> GMT+02:00, offset 7200000
TimeZone.getTimeZone("-05:30")     -> GMT, offset 0

So assigning getTimeZone(exifOffset) directly would still save a shifted date, just using UTC instead of the device zone. Validate the offset first and convert it deliberately (for example through ZoneOffset.of(...), or a validated GMT±HH:mm ID if keeping SimpleDateFormat). Invalid offset text shouldn't silently become a successful GMT parse.

A small fixture for the extracted conversion helper would catch this without a photo/device dependency: DateTimeOriginal = 2026:11:08 10:00:00, OffsetTimeOriginal = +02:00 must resolve to 2026-11-08T08:00:00Z, with the same epoch under two different device-default zones. Add a negative half-hour offset, missing-offset fallback, and a TAG_DATETIME/TAG_OFFSET_TIME pair too.

The current fixDateTaken() writes one calculated timestamp into MediaStore, favorites and date_takens, so checking that conversion before those writes is useful. My probe covers JVM offset handling, not the Android photo-repair workflow.

Alox1d avatar Nov 08 '26 11:11 Alox1d