Skip to content

Commit

Permalink
Proposed fiz for #1703 timewarp pull-exif timezone fails to update Ph…
Browse files Browse the repository at this point in the history
…otos Timezone info when offset_seconds
  • Loading branch information
oPromessa committed Oct 7, 2024
1 parent 808095c commit 36c8332
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion osxphotos/exif_datetime_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def update_photos_from_exif(
)
return None

if dtinfo.offset_seconds:
if dtinfo.offset_seconds is not None:
# update timezone then update date/time
timezone = Timezone(dtinfo.offset_seconds)
tzupdater = PhotoTimeZoneUpdater(
Expand Down
6 changes: 3 additions & 3 deletions osxphotos/exifutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_exif_date_time_offset(

# try to get offset from EXIF:OffsetTimeOriginal
offset = exif.get("EXIF:OffsetTimeOriginal") or exif.get("OffsetTimeOriginal")
if dt and not offset:
if dt and offset is None:
# see if offset set in the dt string
for pattern in (
r"\d{4}:\d{2}:\d{2}\s\d{2}:\d{2}:\d{2}([+-]\d{2}:\d{2})",
Expand All @@ -119,10 +119,10 @@ def get_exif_date_time_offset(
dt = f"{matched.group(1)} 00:00:00"
default_time = True

offset_seconds = exif_offset_to_seconds(offset) if offset else None
offset_seconds = exif_offset_to_seconds(offset) if offset is not None else None

if dt:
if offset:
if offset is not None:
# drop offset from dt string and add it back on in datetime %z format
dt = re.sub(r"[+-]\d{2}:\d{2}$", "", dt)
dt = re.sub(r"\.\d+$", "", dt)
Expand Down

0 comments on commit 36c8332

Please sign in to comment.