From c32f89da7d6e969f101a9c359eb6d26f953e6383 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 10 Jul 2022 13:31:40 -0700 Subject: [PATCH] Use dateutil.parser instead of specific strptime. --- voussoirkit/imagetools.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/voussoirkit/imagetools.py b/voussoirkit/imagetools.py index a98cfd5..21b8654 100644 --- a/voussoirkit/imagetools.py +++ b/voussoirkit/imagetools.py @@ -1,8 +1,10 @@ import copy import datetime +import dateutil.parser import io import PIL.ExifTags import PIL.Image +import re from voussoirkit import pathclass @@ -83,7 +85,8 @@ def get_exif_datetime(image) -> datetime.datetime: if not exif_date: return - return datetime.datetime.strptime(exif_date, '%Y:%m:%d %H:%M:%S') + exif_date = re.sub(r'(\d\d\d\d):(\d\d):(\d\d)', r'\1-\2-\3', exif_date) + return dateutil.parser.parse(exif_date) def pad_to_square(image, background_color=None) -> PIL.Image: '''