From 36c8332258d19402f96ddfd9175f6a6a77af6a61 Mon Sep 17 00:00:00 2001 From: MSP Date: Mon, 7 Oct 2024 17:51:31 +0100 Subject: [PATCH] Proposed fiz for #1703 timewarp pull-exif timezone fails to update Photos Timezone info when offset_seconds --- osxphotos/exif_datetime_updater.py | 2 +- osxphotos/exifutils.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osxphotos/exif_datetime_updater.py b/osxphotos/exif_datetime_updater.py index 0671ff248..949c46cd0 100644 --- a/osxphotos/exif_datetime_updater.py +++ b/osxphotos/exif_datetime_updater.py @@ -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( diff --git a/osxphotos/exifutils.py b/osxphotos/exifutils.py index c1bd0e7f6..b91c0a52a 100644 --- a/osxphotos/exifutils.py +++ b/osxphotos/exifutils.py @@ -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})", @@ -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)