Improve error message for unsupported timezones

This commit is contained in:
Unrud 2018-04-21 11:18:43 +02:00
parent 7173ab3ca1
commit dfc00b26a7

View File

@ -29,6 +29,7 @@ import copy
import math import math
import posixpath import posixpath
import re import re
import sys
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from collections import OrderedDict from collections import OrderedDict
from datetime import date, datetime, timedelta, timezone from datetime import date, datetime, timedelta, timezone
@ -689,7 +690,13 @@ def find_tag_and_time_range(vobject_item):
start = DATETIME_MIN start = DATETIME_MIN
if end is None: if end is None:
end = DATETIME_MAX end = DATETIME_MAX
return tag, math.floor(start.timestamp()), math.ceil(end.timestamp()) try:
return tag, math.floor(start.timestamp()), math.ceil(end.timestamp())
except ValueError as e:
if str(e) == ("offset must be a timedelta representing a whole "
"number of minutes") and sys.version_info < (3, 6):
raise RuntimeError("Unsupported in Python < 3.6: %s" % e) from e
raise
def name_from_path(path, collection): def name_from_path(path, collection):