Skip to content

Commit 93afe66

Browse files
author
Evan Derickson
committed
Use fromisoformat first
1 parent 5a4e2a0 commit 93afe66

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

overpass/api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ def get(self, query, responseformat="geojson", verbosity="body", build=True, dat
8484
or allow the programmer to specify full query manually (False)
8585
:param date: a date with an optional time. Example: 2020-04-27 or 2020-04-27T00:00:00Z
8686
"""
87-
if date:
87+
if date and not isinstance(date, datetime):
88+
# If date is given and is not already a datetime, attempt to parse from string
8889
try:
89-
date = datetime.strptime(date, '%Y-%m-%dT%H:%M:%SZ')
90+
date = datetime.fromisoformat(date)
9091
except ValueError:
91-
date = datetime.strptime(date, '%Y-%m-%d')
92+
# The 'Z' in a standard overpass date will through fromisoformat() off
93+
date = datetime.strptime(date, '%Y-%m-%dT%H:%M:%SZ')
9294
# Construct full Overpass query
9395
if build:
9496
full_query = self._construct_ql_query(

0 commit comments

Comments
 (0)