Fix timezone-dependent getDate timestamp test - #675
Open
MohammedAlkindi wants to merge 1 commit into
Open
Conversation
test_getDate_datetime_timestamp asserted a hardcoded date for a timestamp that getDate converts with datetime.fromtimestamp(), which uses the local timezone. The timestamp is 2019-10-19 20:01:46 UTC, so on any machine east of UTC+3:58 the local date is already 2019-10-20 and the test fails; CI never sees it because hosted runners are UTC. Assert the documented contract (number is a timestamp, converted to the local date) instead of one timezone's rendering of it.
This was referenced Aug 17, 2026
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.
Symptom
pyteston a clean clone fails for any contributor whose machine is east of UTC+3:58 — Dubai, India, China, Japan, most of Australia:CI never sees it because hosted runners run in UTC, and the full-matrix Windows/macOS/Linux jobs all share that timezone.
Mechanism
getDateconverts a number withdatetime.fromtimestamp(), which uses the local timezone — that is its documented contract ("assuming it's a timestamp"). The test's timestamp1571515306is2019-10-19 20:01:46 UTC, so anywhere with an offset of +3:59 or more the local date is already October 20. The hardcodeddt.date(2019, 10, 19)therefore encodes "a timezone west of UTC+4", not the function's behaviour.Fix
Assert the documented contract instead of one timezone's rendering of it:
The sibling
test_getDateTime_datetime_timestampalready avoids this by asserting only the type.What is deliberately unchanged
getDateitself. Local-time interpretation is the vendored dbfpy's long-standing semantics, and changing it would alter written DBF dates for existing users — that would be a behaviour change, not a test fix.Evidence
Reproduced on Windows 11 in UTC+4: before,
1 failed, 182 passedon a clean clone atc8ff4e1; after,183 passed. Also green withTZ=UTCandTZ=America/Los_Angeles— though I'd weight the real-machine result over those, sinceTZhandling on Windows Python is not a full timezone simulation.Added myself to AUTHORS per the contributing guide.