fix: preserve time and offset in ISO datetime strings - #355
Open
ryanduguid wants to merge 1 commit into
Open
ryanduguid wants to merge 1 commit into
ryanduguid wants to merge 1 commit into
Conversation
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.
validate_io_timestamp()parses ISO datetime strings, then combines the result with midnight. This discards the supplied time, fractional seconds and UTC offset. For example, withTIME_ZONE='America/New_York', committing2024-07-01T00:35:27.123456+10:00saves2024-07-01T04:00:00Zinstead of2024-06-30T14:35:27.123456Z.Return parsed datetimes before the date-only conversion. Naive datetime strings use the current timezone when
USE_TZ=Trueand remain naive otherwise. Date-only strings retain their existing midnight behaviour. Regression coverage checks UTC and positive/negative offsets, fractional seconds, timezone settings, date-only inputs and the timestamp saved bycommit_txs().Validation on Windows with Python 3.12.10 and Django 6.0.1, using
uv sync --locked --python 3.12:python manage.py test django_ledger.tests.test_io --noinput: 12 tests pass.python manage.py test --noinput: 59 tests, 6 failures and 8 errors. Untouched upstream5b4787bruns 55 tests with the same 14 failing test names and the same failure/error counts (OFX helpers, transaction forms, UI messages and query counts).no-membererrors in the changed module and upstream source. The test file has no errors.git diff --checkpasses.The complete Linux/Python 3.9 CI and full lint workflow were not reproduced locally. The manifest requires Python 3.11 or newer, and the lint workflow references an absent
brickbox/directory. This change affects newly parsed timestamps; it does not repair previously saved entries.