New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests fail after 2038-01-10 #41
Comments
|
I tried to reproduce your problem and failed: >>> from DateTime import DateTime
>>> dt=DateTime(2038, 10, 7,8,52,44.959838, "UTC")
>>> dt
DateTime('2038/10/07 08:52:44.959838 UTC')
>>> xdt = dt + 0.10 + 3.14 + 6.76 - 10
>>> xdt
DateTime('2038/10/07 08:52:44.959838 UTC')
>>> dt == xdt
TrueYour observation is almost surely due to a rounding effect. Recently, rounding problems caused by a side effect of a compilation with the At your place, I would:
|
|
I found a reproducer: Our CFLAGS contain -O2 and no -Ofast |
|
Bernhard M. Wiedemann wrote at 2022-9-12 21:00 -0700:
I found a reproducer:
```
from DateTime import DateTime
dt = DateTime(2038, 10, 7,8,52,44.959840, "UTC")
xdt = dt + 0.10 + 3.14 + 6.76 - 10
dt == xdt
```
The error is located near the end of the `_parse_args` method:
```
sc = round(sc, 6)
...
self._hour, self._minute, self._second = hr, mn, sc
...
if microsecs is None:
microsecs = long(math.floor(t * 1000000.0))
self._micros = microsecs
```
While the `_second` computation rounds to the nearest microsecond,
the microsecond computation floors instead.
This leads to inconsistent `_second` and `_micros` values.
The `__add__` implementation is based on `_micros`. The error
happens due to an inconsistent `_micros` value after the
`+ 0.10`.
In addition, `__add__` is somewhat suboptimal: it knows the
correct microsecond value but does not pass it; instead it
lets it be computed (wrongly) by `_parse_args`.
Thank you for reporting this bug.
|
|
Just released the fix as https://pypi.org/project/DateTime/4.7/ |
|
I verified, that it is indeed fixed in DateTime-4.7. |
BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)
What I did:
run tests on 2038-01-10
on openSUSE, I do
What I expect to happen:
tests should continue to pass in future
What actually happened:
3 tests failed:
What version of Python and Zope/Addons I am using:
openSUSE-Tumbleweed 20220907
python-3.8
The text was updated successfully, but these errors were encountered: