Skip to content

fix: preserve time and offset in ISO datetime strings - #355

Open
ryanduguid wants to merge 1 commit into
arrobalytics:developfrom
ryanduguid:fix/preserve-iso-datetime-timestamps
Open

ryanduguid wants to merge 1 commit into
arrobalytics:developfrom
ryanduguid:fix/preserve-iso-datetime-timestamps

Conversation

@ryanduguid

Copy link
Copy Markdown

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, with TIME_ZONE='America/New_York', committing 2024-07-01T00:35:27.123456+10:00 saves 2024-07-01T04:00:00Z instead of 2024-06-30T14:35:27.123456Z.

Return parsed datetimes before the date-only conversion. Naive datetime strings use the current timezone when USE_TZ=True and 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 by commit_txs().

Validation on Windows with Python 3.12.10 and Django 6.0.1, using uv sync --locked --python 3.12:

  • The new regression cases fail on the original implementation and pass with this fix.
  • 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 upstream 5b4787b runs 55 tests with the same 14 failing test names and the same failure/error counts (OFX helpers, transaction forms, UI messages and query counts).
  • Scoped Pylint with the repository's error-only options reports the same 10 existing mixin no-member errors in the changed module and upstream source. The test file has no errors.
  • git diff --check passes.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant