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

Add isoparse example to the documentation #1073

Open
dpriskorn opened this issue Aug 24, 2020 · 2 comments · May be fixed by #1322
Open

Add isoparse example to the documentation #1073

dpriskorn opened this issue Aug 24, 2020 · 2 comments · May be fixed by #1322

Comments

@dpriskorn
Copy link

dpriskorn commented Aug 24, 2020

I'm trying to parse this: "2020-08-20T03:33:46.000Z" and it does not seem to work. I have not found any examples in the documentation that I can try so I don't know if if I'm doing something wrong or if I found a bug.

I get these errors:

>>> import dateutil.parser
>>> dateutil.parser.isoparser("2020-08-20T03:33:46")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/dateutil/parser/isoparser.py", line 52, in __init__
    raise ValueError('Separator must be a single, non-numeric ' +
ValueError: Separator must be a single, non-numeric ASCII character 
>>> dateutil.parser.isoparser("2020-08-20T03:33:46.000Z")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/dateutil/parser/isoparser.py", line 52, in __init__
    raise ValueError('Separator must be a single, non-numeric ' +
ValueError: Separator must be a single, non-numeric ASCII character

I tried supplying a separator like this:

>>> dateutil.parser.isoparser("2020-08-20T03:33:46.000Z", sep="T")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got multiple values for argument 'sep'

I also tried with a string from the RFC standard but that failed too:

>>> dateutil.parser.isoparser("1997-07-16T19:20+01:00")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/dateutil/parser/isoparser.py", line 52, in __init__
    raise ValueError('Separator must be a single, non-numeric ' +
ValueError: Separator must be a single, non-numeric ASCII character
@ffe4 ffe4 added the isoparser label Aug 24, 2020
@ffe4
Copy link
Member

ffe4 commented Aug 24, 2020

You are actually using the class isoparser instead of the documented method isoparse. After fixing the typo it should work:

>>> from dateutil.parser import isoparse
>>> isoparse("2020-08-20T03:33:46.000Z")
datetime.datetime(2020, 8, 20, 3, 33, 46, tzinfo=tzutc())

An example to copy and paste would have probably avoided this issue, so adding one to the docs definitely wouldn't hurt.

@king-11
Copy link

king-11 commented May 17, 2021

@ffe4 I would like to work on this could you tell me how should I make the PR

@rbarman rbarman linked a pull request Nov 22, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants