fix(utils): datetime_to_epoch function is fixed to timezone aware epoch#37979
fix(utils): datetime_to_epoch function is fixed to timezone aware epoch#37979hainenber merged 2 commits intoapache:masterfrom
Conversation
Code Review Agent Run #05de82Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #37979 +/- ##
==========================================
+ Coverage 60.48% 66.43% +5.94%
==========================================
Files 1931 668 -1263
Lines 76236 51322 -24914
Branches 8568 5776 -2792
==========================================
- Hits 46114 34096 -12018
+ Misses 28017 15840 -12177
+ Partials 2105 1386 -719
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@tzercin thanks for opening out a PR! That said, can you fix the lint issue reported by Ruff, i.e. the un-sorted import? |
|
Oh sorry, I fixed it now! |
Code Review Agent Run #a3a383Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Thanks @tzercin! |
SUMMARY
Fixes an epoch-shift bug in Explore Results when switching “Formatted date” ↔ “Original value” by correcting timezone-aware datetime → epoch conversion to preserve the absolute instant.
Convert tz-aware datetimes to UTC using astimezone(pytz.utc) instead of re-labeling tzinfo with replace(tzinfo=UTC).
Add a regression unit test covering tz-aware datetime serialization to epoch.
replace(tzinfo=UTC) changes the represented instant for tz-aware datetimes, causing offsets like +8 hours in the serialized epoch; astimezone(UTC) performs a true conversion and keeps the instant consistent.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:


After:

TESTING INSTRUCTIONS
docker run -d --name postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e TZ=Asia/Shanghai -p 5432:5432 postgres:latestADDITIONAL INFORMATION