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

Dates ending with Z timezone not recognized if there is no millisecond #37

Closed
rawouter opened this issue Feb 6, 2017 · 4 comments · Fixed by #38
Closed

Dates ending with Z timezone not recognized if there is no millisecond #37

rawouter opened this issue Feb 6, 2017 · 4 comments · Fixed by #38

Comments

@rawouter
Copy link
Contributor

rawouter commented Feb 6, 2017

Let me start with: this is exactly the module I was looking for, thanks a lot!

I'm having an annoying bug however, I have dates ending the with "Z" keyword for the timezone, which is ISO 8601 compliant but the module fails to parse it:

>>> list(datefinder.find_dates('INFO[2017-02-03T09:04:08Z] Done job'))
[]

>>> list(datefinder.find_dates('INFO[2017-02-03T09:04:08] Done job'))
[datetime.datetime(2017, 2, 3, 9, 4, 8)]
@ranchodeluxe
Copy link
Collaborator

@rawouter: nice eye

It looks like the regex parser is expecting a microsecond too. Not sure if the microsecond is a required part of ISO 8601. The regex parser might want to be flexible enough for both.

In [1]: import datefinder

In [2]: list(datefinder.find_dates('INFO[2017-02-03T09:04:08.023423Z] Done job'))
Out[2]: [datetime.datetime(2017, 2, 3, 9, 4, 8)]

@rawouter
Copy link
Contributor Author

rawouter commented Feb 6, 2017

Thanks for your fast reply, I'm not an ISO 8601 pro so I'll leave it up to you, but indeed if the parser can be flexible enough that would be great ;-)

Talking about microsecond, I'm dealing with very nasty all kind of logs; these also fail I can also open an other issue if you want:

>>> list(datefinder.find_dates('[2017-02-03 07:52:36.958]', source=True))
[(datetime.datetime(2017, 2, 3, 7, 52, 36), '2017-02-03 07:52:36')]

--> missing the .958

@ranchodeluxe
Copy link
Collaborator

thanks, that's good to know also

@rawouter rawouter changed the title Dates ending with Z timezone not recognized Dates ending with Z timezone not recognized if there is no millisecond Feb 7, 2017
@rawouter
Copy link
Contributor Author

rawouter commented Feb 7, 2017

Proposing a fix for issues I discovered, please have a look at #38 for more details.

Thanks!

akoumjian added a commit that referenced this issue Feb 17, 2017
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 a pull request may close this issue.

2 participants