summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdexcom_reader/dexcom_dumper.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/dexcom_reader/dexcom_dumper.py b/dexcom_reader/dexcom_dumper.py
index 78e9841..ca85b0b 100755
--- a/dexcom_reader/dexcom_dumper.py
+++ b/dexcom_reader/dexcom_dumper.py
@@ -304,11 +304,27 @@ def test0():
304 for t in parseable_record_types(): 304 for t in parseable_record_types():
305 remote_update(t) 305 remote_update(t)
306 306
307from datetime import tzinfo, timedelta, datetime
308
309ZERO = timedelta(0)
310
311class UTCtzinfo(tzinfo):
312 def utcoffset(self, dt):
313 return ZERO
314
315 def tzname(self, dt):
316 return "UTC"
317
318 def dst(self, dt):
319 return ZERO
320
321UTC = UTCtzinfo()
322
307class JSON_Time(json.JSONEncoder): 323class JSON_Time(json.JSONEncoder):
308 def default(self, o): 324 def default(self, o):
309 if isinstance(o, datetime): 325 if isinstance(o, datetime):
310 if o.tzinfo is None: 326 if o.tzinfo is None:
311 from pytz import UTC 327
312 return o.replace(tzinfo=UTC).isoformat() 328 return o.replace(tzinfo=UTC).isoformat()
313 else: 329 else:
314 return o.isoformat() 330 return o.isoformat()