Skip to content
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

Better error message for BCE years #162

Open
wants to merge 1 commit into
base: movermeyer/python_313_support
Choose a base branch
from

Conversation

movermeyer
Copy link
Collaborator

What are you trying to accomplish?

Fixes #156

What approach did you choose and why?

Improved the error message specifically for the cases where someone attempts to parse BCE years.

What should reviewers focus on?

🤷 Our performance guarantees are on the happy path. On the error path, we try to give the best error messages possible.

The impact of these changes

Users will be be given a better error message in this specific case.

Testing

>>> from ciso8601 import parse_datetime
>>> parse_datetime("-2014-01-02")
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    parse_datetime("-2014-01-02")
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
ValueError: Invalid character while parsing year ('-', Index: 0). While valid ISO 8601 years, BCE years are not supported by Python's `datetime` objects.

@movermeyer movermeyer marked this pull request as ready for review November 10, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant