Skip to content

Commit 48dff8b

Browse files
committed
fix: don't force timestamps to second-precision. allow ms & us
1 parent b6c7ee1 commit 48dff8b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

escape_helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def sparql_escape_datetime(obj):
1313
if not isinstance(obj, datetime.datetime):
1414
warn("You are escaping something that isn't a datetime with \
1515
the 'sparql_escape_datetime'-method. Implicit casting will occurr.")
16-
obj = datetime.datetime.fromisoformat(str(obj))
17-
return '"{}"^^xsd:dateTime'.format(obj.isoformat(timespec="seconds"))
16+
obj = datetime.datetime.fromisoformat(str(obj)) # only supports 3 or 6 digit microsecond notation (https://docs.python.org/3.7/library/datetime.html#datetime.datetime.fromisoformat)
17+
return '"{}"^^xsd:dateTime'.format(obj.isoformat())
1818

1919
def sparql_escape_date(obj):
2020
if not isinstance(obj, datetime.date):
@@ -27,8 +27,8 @@ def sparql_escape_time(obj):
2727
if not isinstance(obj, datetime.time):
2828
warn("You are escaping something that isn't a time with \
2929
the 'sparql_escape_time'-method. Implicit casting will occurr.")
30-
obj = datetime.time.fromisoformat(str(obj))
31-
return '"{}"^^xsd:time'.format(obj.isoformat(timespec="seconds"))
30+
obj = datetime.time.fromisoformat(str(obj)) # only supports 3 or 6 digit microsecond notation (https://docs.python.org/3.7/library/datetime.html#datetime.time.fromisoformat)
31+
return '"{}"^^xsd:time'.format(obj.isoformat())
3232

3333
def sparql_escape_int(obj):
3434
if not isinstance(obj, int):

0 commit comments

Comments
 (0)