Skip to content

fix: emit timezone-aware UTC timestamps in MQTT payloads - #64

Merged
Cisien merged 1 commit into
Cisien:mainfrom
maxious:fix/timestamp-timezone-aware
Jun 5, 2026
Merged

Cisien merged 1 commit into
Cisien:mainfrom
maxious:fix/timestamp-timezone-aware

Conversation

@maxious

@maxious maxious commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Change datetime.now().isoformat() to datetime.now(timezone.utc).isoformat() in message_parser.py and mqtt_publish.py so all MQTT payloads carry an explicit UTC offset (+00:00). Fix removes the "Naive observer clock" warning introduced in CoreScope PR Kpa-clawbot/CoreScope#1480.

Before: "2026-06-05T12:00:00.123456" (naive, no timezone)
After: "2026-06-05T12:00:00.123456+00:00" (timezone-aware UTC)

Ecosystem alignment

This aligns the format across the MeshCore MQTT ecosystem:

Producer Timestamp format
pyMC_Repeater (status/raw) +00:00 ISO
meshcore-ha (status/packet) naive ISO (PR meshcore-dev/meshcore-ha#259)
meshcoretomqtt naive ISO (this PR)
meshcore-packet-capture naive ISO (PR: )

Change `datetime.now().isoformat()` to `datetime.now(timezone.utc).isoformat()`
in message_parser.py and mqtt_publish.py so all MQTT payloads carry an
explicit UTC offset (+00:00).

Before: "2026-06-05T12:00:00.123456"        (naive, no timezone)
After:  "2026-06-05T12:00:00.123456+00:00"  (timezone-aware UTC)

## Ecosystem alignment

This matches the existing dominant format across the MeshCore MQTT ecosystem:

| Producer                    | Timestamp format  |
|-----------------------------|-------------------|
| pyMC_Repeater (status/raw)  | +00:00 ISO        |
| meshcore-ha (status/packet) | +00:00 ISO (PR #259) |
| meshcoretomqtt (this)       | +00:00 ISO        |
| meshcore-packet-capture     | naive ISO (separate tool for Companion radios) |

## Consumer compatibility

- **LetsMesh.net** (primary consumer, closed-source): timestamp field is
  pass-through metadata; +00:00 has been running in production for months
  with no issues. The actual MeshCore packet timestamp is decoded from
  the `raw` hex payload by meshcore-decoder, not from this field.
- **CoreScope** (self-hosted analyzer, v3.8.3+): Go `time.Parse(time.RFC3339)`
  accepts both `Z` and `+00:00` as zone-aware. Fix removes the "Naive
  observer clock" warning introduced in CoreScope PR #1480.
- **meshcore-ha** (Home Assistant integration, PR #259): switched to
  `datetime.now(timezone.utc).isoformat()` producing +00:00; test accepts
  both +00:00 and Z.

## Verification

- 329 tests passed, 28 skipped (no regressions)
- LSP diagnostics clean on both changed files
- Python ast.parse validates both files
- `datetime.now(timezone.utc).isoformat()` produces format verified
  with assert: `"+00:00" in aware_timestamp`
@Cisien
Cisien merged commit f486694 into Cisien:main Jun 5, 2026
1 check passed
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