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

Texts with date containing day name and exact date parsed incorrectly: #151

Closed
ghost opened this issue Dec 16, 2015 · 5 comments
Closed

Comments

@ghost
Copy link

ghost commented Dec 16, 2015

In this case, "Tuesday" is parsed correctly, "Dec 22nd" is parsed correctly. "Tuesday, dec 22nd" is parsed as the 28th - It finds the "December 22nd" first, than adds the number of days between now and tuesday (6)
Perhaps when there aren't qualifiers like tuesday after dec 22nd, it should satisfy with using the date it found.

>>> c.parse("tuesday")
(time.struct_time(tm_year=2015, tm_mon=12, tm_mday=22, tm_hour=16, tm_min=38, tm_sec=7, tm_wday=1, tm_yday=356, tm_isdst=-1), 1)
>>> c.parse("dec 22nd")
((2015, 12, 22, 16, 38, 2, 2, 350, 0), 1)

>>> c.parse("tuesday, dec 22nd")
(time.struct_time(tm_year=2015, tm_mon=12, tm_mday=28, tm_hour=16, tm_min=37, tm_sec=57, tm_wday=0, tm_yday=362, tm_isdst=-1), 1)
@bear
Copy link
Owner

bear commented Dec 16, 2015

The issue with this is that "Tuesday" and "Dec 22nd" are both valid dates so the parser will always return a date that satisfies all of the date expressions found.

I do like the idea of checking to see if any modifiers are present but we then still have the "which date wins" choice to make :/

@ghost
Copy link
Author

ghost commented Dec 16, 2015

Well, right now it doesn't satisfy any of them.

Feels like there are levels of accuracy for a date - and it seems like a specific formatted date is better everything else. When talking about far-away dates like "Thursday March 17th" - someone might accidentally write the wrong day of week next to it.
I think I'll stop parsing for more date-parts once I get something accurate like this.

Or we can change the reference date used to calculate the day offset for Thursday, so it will add 0 days since this is a correct combination of day and date.

Thanks!

@bear
Copy link
Owner

bear commented Dec 16, 2015

@eyal-meekan thanks for working thru this, if you come up with a flow that solves this issue for you then please do submit a PR - we can always add/change the code and then document why.

thanks!

@jonklein
Copy link
Collaborator

I believe this is a dupe of #165 and can be closed out now.

@bear
Copy link
Owner

bear commented Aug 23, 2016

@ghost closing this as @jonklein has fixed the issue in issue #165

@bear bear closed this as completed Aug 23, 2016
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

No branches or pull requests

2 participants