-
Notifications
You must be signed in to change notification settings - Fork 58
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
BCE years trigger ISO8601Error #79
Comments
I'm also affected but note this is known behaviour: isodate/src/isodate/isodates.py Line 6 in 8856fdf
Probably the fix is to replace the built-in Python library with another implementation, e.g., NumPy, but that is also probably a breaking change. |
@dymil hit the nail on the head with the response. I wrote this so I would understand the problem a little better. Python's >>> from datetime import datetime
>>> datetime(63,1,1)
datetime.datetime(63, 1, 1, 0, 0)
>>> datetime(-63,1,1)
ValueError: year -63 is out of range Python date libraries like Pendulum ( The I agree with @dymil NumPy is a great alternative that does the ISO parsing itself and supports negative years. If there were another library that took a |
Thanks for your clarifications! I have worked with flexidate before, maybe it is worth a try. |
@jonasengelmann If you want to parse negative years per the current documentation, it should be called like this. >>> isodate.parse_date('-0663-01-01', expanded=True)
ValueError: year -663 is out of range I think a If you want, I can put a PR together to allow a FlexiDate object to be able to passed instead of the Python date function. Only if you want me to. Here's what I'd propose: >>> import flexidate
>>> isodate.parse_date('-0663-01-01', expanded=True, date_obj=flexidate.Flexidate)
<class 'flexidate.FlexiDate'> -0663-01-01 This has the benefit of adding no more dependencies to the isodate library, but still allowing it to be useful for this edge case. |
I work with historical data and also BCE dates, however these currently result in an error, e.g.:
Unrecognised ISO 8601 date format: '-0663-01-01'
Yet according to ISO 8601 BCE years should be denoted with a preceding - sign, e.g.
-0002-04-12
is even listed as an example.The text was updated successfully, but these errors were encountered: