Repository navigation
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two helpers to
MessageEntityfor 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_timereturns the current local time whenmessageTimeis 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, orNonewhen 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, orNone.createTimeis often missing on EU accounts, per the author.message_timeis unchanged, including thenow()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
createTimeis in milliseconds comes from the author's data. I haven't confirmed it independently.https://claude.ai/code/session_013xKSpu8ev4cxQNsitcCidm