Skip to content

fix: serialize epoch datetimes on Windows - #242

Draft
ryanduguid wants to merge 3 commits into
XeroAPI:masterfrom
ryanduguid:agent/fix-windows-datetime-serialization
Draft

fix: serialize epoch datetimes on Windows#242
ryanduguid wants to merge 3 commits into
XeroAPI:masterfrom
ryanduguid:agent/fix-windows-datetime-serialization

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • retain datetime.timestamp() as the normal path so platform local-time, DST gap and fold semantics remain unchanged
  • fall back to datetime arithmetic only when the platform rejects an out-of-range value, using Windows timezone data that supports pre-epoch values
  • preserve declared offsets for aware datetimes and UTC-midnight semantics for dates
  • add aware, naive and date negative-epoch regressions plus normal, ambiguous and nonexistent local-time parity cases

Why

On Windows in a positive UTC offset, serialising datetime.fromtimestamp(0) currently raises OSError: [Errno 22] Invalid argument because the local representation crosses before the platform epoch. The same test passes on Linux, so the existing Linux-only workflow did not expose it.

Validation

  • focused serializer suite: 81 passed on Windows
  • full suite with all nine Prism mocks: 177 passed on Windows
  • fatal-error flake8 selection passed
  • git diff --check

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