Skip to content

Commit 8d8bf07

Browse files
mikijovkannappanr
authored andcommitted
Add support for ISO time with and without fractional seconds. (#777)
1 parent 13cf194 commit 8d8bf07

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

minio/parsers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,14 @@ def _iso8601_to_localized_time(date_string):
360360
:param date_string: iso8601 formatted date string.
361361
:return: :class:`datetime.datetime`
362362
"""
363-
parsed_date = datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')
363+
364+
# Handle timestamps with and without fractional seconds. Some non-AWS
365+
# vendors (e.g. Dell EMC ECS) are not consistent about always providing
366+
# fractional seconds.
367+
try:
368+
parsed_date = datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')
369+
except ValueError:
370+
parsed_date = datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%SZ')
364371
localized_time = pytz.utc.localize(parsed_date)
365372
return localized_time
366373

0 commit comments

Comments
 (0)