Skip to content

feat: message time helpers that return None instead of now() - #60

Open
nanomad wants to merge 1 commit into
developfrom
feat/message-time-helpers
Open

nanomad wants to merge 1 commit into
developfrom
feat/message-time-helpers

Conversation

@nanomad

@nanomad nanomad commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Adds two helpers to MessageEntity for messages with a missing or unreadable time.

Credit: this is James Townsend's (@townsmcp) work. It comes from the message helper part of commit 5bc66b8 in his fork, where it sat with other changes. I took only that part and kept him as the commit author.

The problem

MessageEntity.message_time returns the current local time when messageTime is missing or can't be parsed. A message with no time then looks brand new, which is wrong when you decide whether a message is old.

Changes

  • message_time_or_none: the parsed time, or None when it's missing or unreadable. The result is naive: SAIC sends local server time with no timezone (CET/CEST on EU servers), so it can't be compared with UTC.
  • create_time_utc: createTime (Unix milliseconds) as a timezone-aware UTC datetime, or None. createTime is often missing on EU accounts, per the author.
  • message_time is unchanged, including the now() fallback, so existing callers behave as before.
  • tests/test_message_times.py: all three known date formats, naive versus aware, missing and unreadable inputs, and the unchanged fallback.

ruff, mypy, pylint and pytest pass locally on Python 3.13.

Not checked

That createTime is in milliseconds comes from the author's data. I haven't confirmed it independently.

https://claude.ai/code/session_013xKSpu8ev4cxQNsitcCidm

MessageEntity.message_time_or_none and create_time_utc return None when a message has no (readable) time, instead of substituting now(). message_time behaves as before.

Originally written by James Townsend (townsmcp) in https://github.com/townsmcp/saic-python-client-ng, taken from commit 5bc66b8 (the message helper part only).

This branch has not been deployed

No deployments
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