-
-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation
Description
Checklist
- I am sure the error is coming from Pyrogram's code and not elsewhere
- I have searched in the issue tracker for similar bug reports, including closed ones
- I ran
pip3 install https://github.com/TelegramPlayground/pyrogram/archive/dev.zip --force-reinstall
and reproduced the issue using the latest development version
Description
Issue:
The date parameter in the Message object contains an incorrectly formatted datetime object, where tzinfo is set to UTC instead of the expected Europe/Kiev timezone.
This causes the following problem:
last_message_time = messages.date returns a time like 2025-08-19 11:00:12+00:00 (UTC).
datetime_now = datetime.now(last_message_time.tzinfo) returns the current time in UTC (e.g., 2025-08-19 10:19:27.040198+00:00).
As a result, datetime_now appears to be earlier than last_message_time, making it seem as if messages were received from the future.
Steps to reproduce
- Fetch a Message object where the date field is incorrectly formatted with tzinfo=UTC.
- Extract the date value from the Message object (e.g., last_message_time = message.date).
- Get the current time using the timezone from the Message object:
- Copy datetime_now = datetime.now(last_message_time.tzinfo)
- Compare last_message_time and datetime_now.
- Observe that datetime_now is earlier than last_message_time, which is impossible in reality.
Code example
last_message_time = messages.date
# Current time
datetime_now = datetime.now(last_message_time.tzinfo)
# Calculate the time difference
inactive_threshold = (datetime_now - last_message_time).total_seconds()
Logs
Copilot
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentation