zopefoundation / DateTime

This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.
Other
19 stars 25 forks source link

fix round problem with addition for dates beyond 2038 #42

Closed d-maurer closed 2 years ago

d-maurer commented 2 years ago

Fixes #41.

41 has been caused by an inconsistent computation of _second and _micros in _parse_args: the first rounded to the nearest microsecond, the second floored. The PR rounds in both cases.

In addition, the PR makes __add__ pass its computed microsecond value to the DateTime constructor rather than let it be recomputed in _parse_args.

d-maurer commented 2 years ago

Could you please add a simple unit test? Code for that already exists in the issue discussion.

Checks added