Skip to content

Update raw_event.py to use ISO timestamps#131

Open
VTDARKSIM wants to merge 1 commit into
jwoglom:masterfrom
VTDARKSIM:VTDARKSIM-patch-1
Open

Update raw_event.py to use ISO timestamps#131
VTDARKSIM wants to merge 1 commit into
jwoglom:masterfrom
VTDARKSIM:VTDARKSIM-patch-1

Conversation

@VTDARKSIM
Copy link
Copy Markdown

Changed the eventTimestamp to use isoformat, hopefully eliminating the fatal mismatch with nightscout.

Changed the eventTimestamp to use isoformat, hopefully eliminating the fatal mismatch with nightscout.
@jwoglom
Copy link
Copy Markdown
Owner

jwoglom commented Feb 18, 2026

hi @VTDARKSIM , can you give some additional context for what you're observing?

@VTDARKSIM
Copy link
Copy Markdown
Author

Of course!
I'm fairly new to this so forgive me if I don't see the whole picture yet. I noticed I would routinely stop seeing tandem data in nightscout, and my tconnectsync logs were showing repeated errors like:

API request using an invalid date: 2026-02-16+23:23:17-05:00 Error: Cannot parse 2026-02-16+23:23:17-05:00 as a valid ISO-8601 date at /opt/app/lib/server/query.js:71:17 at Array.forEach (<anonymous>) at enforceDateFilter (/opt/app/lib/server/query.js:62:28) at create (/opt/app/lib/server/query.js:120:5) at query_for (/opt/app/lib/server/treatments.js:121:12) at Function.list (/opt/app/lib/server/treatments.js:115:13) at /opt/app/lib/api/treatments/index.js:96:22 at Layer.handle [as handle_request] (/opt/app/node_modules/express/lib/router/layer.js:95:5) at next (/opt/app/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/opt/app/node_modules/express/lib/router/route.js:112:3) tick 2026-02-18T19:46:43.032Z DEBUG nightscout-connect { now: 2026-02-18T19:46:43.032Z, type: 'heartbeat', sig: 'internal://heartbeat/8547', beat: 8547, interval: 60000, started: 2026-02-12T21:19:16.315Z }

The timestamps appear to originate in raw_event.py and have a '+' rather than a 'T' like ISO-8601 requires. It seems like the errors occur in a number of downstream modules (query.js, treatments.js, index.js, route.js, etc.) when trying to parse them, so it may be why I'm seeing the 'cannot parse' errors and an absence of data.

The change seems to be working on my end, but of course review and do what you need to do. Either way, I appreciate all you've done - this is awesome!

@jwoglom
Copy link
Copy Markdown
Owner

jwoglom commented Feb 18, 2026

I think str(timestamp) and timestamp.isoformat() will end up being the same:

>>> import arrow
>>> arrow.get()
<Arrow [2026-02-18T23:45:03.638161+00:00]>
>>> str(arrow.get())
'2026-02-18T23:45:07.183138+00:00'
>>> arrow.get().isoformat()
'2026-02-18T23:45:15.679152+00:00'

@VTDARKSIM
Copy link
Copy Markdown
Author

I'm not getting the errors anymore on my local edited copy, but perhaps its a coincidence. In any event, it's working and I'm happy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants