nuodb-python icon indicating copy to clipboard operation
nuodb-python copied to clipboard

Support timezone-aware datetime objects

Open butson opened this issue 6 months ago • 5 comments

connection:

  • Added support for explicit TimeZone connection property

datatype:

  • Use Julian calendar for date/datetime before 1582 Oct 4. When the Gregorian calendar was introduced: . The day after October 4, 1582 (Julian) became October 15, 1582 (Gregorian). . That 10-day jump is not accounted for in C's calendar logic. . Julian calendar handles leap years differently. The utc calendar the engine is using understands this the python functions based on C calendar logic do not.
  • time.mktime , time.localtime don't support older dates while engine does changing to use calendar above and calculate time, avoid these issues.
  • use of datetime + timezone should handle daylight savings times and not be off by an hour.

tests:

  • Use connection property TimeZone to change timezone
  • Support timezone-aware datetime
  • Use pytz correctly with localize if pytz is used
  • Use zoneinfo.ZoneInfo if available

encodedsession:

  • Manage and verify TimeZone settings on per connection basis
  • Allows connections with different TimeZone setting from same application

requirements.txt:

  • Add requirement for tzlocal, should be available on all supported python versions. There is a change in api between releases , this is handled in the code.

butson avatar Apr 25 '25 16:04 butson