[BUG]+[FIX] Correct 1-hour offset on messages timestamps #124
Labels
bug
Something isn't working
enhancement
New feature or request
pending for release
Feature or bug fix to be released
Hi Knugi,
i ve been wondering, why there is a time shift of 1 hour of the messages timestamps. The error is in utility.py:
Instead of:
'APPLE_TIME = datetime.timestamp(datetime(2001, 1, 1))'
you have to use:
APPLE_TIME = datetime.timestamp(datetime(2001, 1, 1, tzinfo=timezone.utc))'
add from datetime import timezone
Why the 1-Hour Difference Happens:
In your calculation (APPLE_TIME), the local time is created based on the system’s time zone, and when you call timestamp(), it converts the local time to UTC. If your system is in a time zone with a 1-hour offset from UTC (e.g., UTC+1 or a daylight-saving adjustment), the timestamp generated will reflect that conversion and the 1-hour shift.
For example, if your system is set to UTC+1, calling timestamp() on datetime(2001, 1, 1) will convert it to UTC. The difference between the time zone (UTC+1) and UTC will cause a 1-hour shift.
If you want to use APPLE_TIME correctly, you should adjust for the time zone by considering the system’s local time zone or ensuring you are always working with UTC time. To ensure consistent results, it’s always best to work with UTC time when dealing with timestamps, or explicitly handle time zone offsets.
you could also use:
APPLE_TIME = datetime(2001, 1, 1, tzinfo=timezone.utc).timestamp()
OR
978307200 + msg.timestamp (978307200 = 31Years)
Let me know, if you need further explanation
The text was updated successfully, but these errors were encountered: