Use a stdlib method for _to_epoch_time on py3
This also works around a bug in Python 3.6.0 on Windows: see
@@ -503,6 +503,10 @@ def _to_epoch_time(date):
"""Convert a `datetime` object to an integer number of seconds since
the (local) Unix epoch.
"""
+ if hasattr(date, 'timestamp'):
+ # The `timestamp` method exists on Python 3.3+.
+ return int(date.timestamp())
+ else:
epoch = datetime.fromtimestamp(0)
delta = date - epoch
return int(delta.total_seconds())
