Skip to content

Commit b587887

Browse files
committed
Marshalling: Remove custom encoding for datetime and date types
1 parent cad5509 commit b587887

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

src/crate/client/http.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# software solely pursuant to the terms of the relevant commercial agreement.
2121

2222

23-
import calendar
2423
import heapq
2524
import io
2625
import logging
@@ -30,11 +29,10 @@
3029
import ssl
3130
import threading
3231
from base64 import b64encode
33-
from datetime import date, datetime, timezone
32+
from datetime import datetime, timezone
3433
from decimal import Decimal
3534
from time import time
3635
from urllib.parse import urlparse
37-
from uuid import UUID
3836

3937
import orjson
4038
import urllib3
@@ -95,21 +93,9 @@ def cratedb_json_encoder(obj):
9593
Encoder function for orjson.
9694
9795
https://github.com/ijl/orjson#default
98-
https://github.com/ijl/orjson#opt_passthrough_datetime
9996
"""
100-
if isinstance(obj, (Decimal, UUID)):
97+
if isinstance(obj, (Decimal,)):
10198
return str(obj)
102-
if isinstance(obj, datetime):
103-
if obj.tzinfo is not None:
104-
delta = obj - epoch_aware
105-
else:
106-
delta = obj - epoch_naive
107-
return int(
108-
delta.microseconds / 1000.0
109-
+ (delta.seconds + delta.days * 24 * 3600) * 1000.0
110-
)
111-
if isinstance(obj, date):
112-
return calendar.timegm(obj.timetuple()) * 1000
11399
return obj
114100

115101

0 commit comments

Comments
 (0)