diff options
Diffstat (limited to 'dexcom_reader/dexcom_dumper.py')
-rwxr-xr-x | dexcom_reader/dexcom_dumper.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/dexcom_reader/dexcom_dumper.py b/dexcom_reader/dexcom_dumper.py index 18724ac..6cfc720 100755 --- a/dexcom_reader/dexcom_dumper.py +++ b/dexcom_reader/dexcom_dumper.py | |||
@@ -286,11 +286,27 @@ def test0(): | |||
286 | for t in parseable_record_types(): | 286 | for t in parseable_record_types(): |
287 | remote_update(t) | 287 | remote_update(t) |
288 | 288 | ||
289 | from datetime import tzinfo, timedelta, datetime | ||
290 | |||
291 | ZERO = timedelta(0) | ||
292 | |||
293 | class UTCtzinfo(tzinfo): | ||
294 | def utcoffset(self, dt): | ||
295 | return ZERO | ||
296 | |||
297 | def tzname(self, dt): | ||
298 | return "UTC" | ||
299 | |||
300 | def dst(self, dt): | ||
301 | return ZERO | ||
302 | |||
303 | UTC = UTCtzinfo() | ||
304 | |||
289 | class JSON_Time(json.JSONEncoder): | 305 | class JSON_Time(json.JSONEncoder): |
290 | def default(self, o): | 306 | def default(self, o): |
291 | if isinstance(o, datetime): | 307 | if isinstance(o, datetime): |
292 | if o.tzinfo is None: | 308 | if o.tzinfo is None: |
293 | from pytz import UTC | 309 | |
294 | return o.replace(tzinfo=UTC).isoformat() | 310 | return o.replace(tzinfo=UTC).isoformat() |
295 | else: | 311 | else: |
296 | return o.isoformat() | 312 | return o.isoformat() |