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
timezone allows no offset from range (23:59, 24:00) #81823
Comments
https://bugs.python.org/issue5288 changed datetime.timezone to accept sub-minute offsets. The C implementation allows offsets from range (23:59, 24:00) while the python implementation does not: # C
>>> timezone(timedelta(seconds=86399))
datetime.timezone(datetime.timedelta(seconds=86399))
# Python
>>> timezone(timedelta(seconds=86399))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cpython/Lib/datetime.py", line 2194, in __new__
raise ValueError("offset must be a timedelta "
ValueError: offset must be a timedelta strictly between -timedelta(hours=24) and timedelta(hours=24). This is because _maxoffset is defined as timedelta(hours=23, minutes=59) Second issue: The (undocumented) "min" and "max" attributes (both C and python) show 23:59 (Same applies to the minimums) |
I agree that the C and Python behavior should be the same, and both of them should allow all offsets less than 24 hours. I'm actually quite surprised we don't have a test for this in |
I have been thinking about this more and I think the two issues ( My reasoning is that a change of the value of |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: