You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dateparser parses years as a date when STRICT_PARSING = True #356
Reacted by Francesco, Shiva, Konstantin Lopuhin, Rex W. Douglass, Víctor Ruiz, Kevin Lloyd Bernal, Nadja Herger, Brett Randall, rjdavy, Nisarg Vinchhi and 2 more
I investigated a bit this issue and I'm sharing what I've found so far.
Following there are two approaches to this problem:
Parsing a date with or without STRICT_PARSING parameter should use the same parser, and return the same result in order to keep consistency. After parsing the date/time string, we check for STRICT_PARSING parameter and return None if it's incomplete.
Currently, if the date is incomplete and STRICT_PARSING is set, it keeps trying to parse the data using other formats, so we end up with different results depending on if you are using STRICT_PARSING or not.
Other approach would be to not parse complete dates from 4 digits data. Parsing 4 digits as complete dates is generating quite weird results, for example:
I'm having the exact same issue. Ideally, I would expect None to be returned when executing something like this: dateparser.parse('2011', settings={'STRICT_PARSING': True})
Are there any updates on this?
Seeing this same issue. I personally think that without the date separators, an input of a number should return None if strict parsing has been set to true
Right now, I see this
`import sys
import dateparser
print(sys.version)
print(dateparser.version)
print("date = ", dateparser.parse('1024', settings={'STRICT_PARSING':True}))
print("date = ", dateparser.parse('March', settings={'STRICT_PARSING':True}))
print("date = ", dateparser.parse('1024823', settings={'STRICT_PARSING':True}))
`
With the output as:
3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] 0.7.1 date = 2010-02-04 00:00:00 date = None date = 4823-10-02 00:00:00
I think both the first and third cases should return None
I know this doesn't fix the issue 100%, as you have to add specific settings, but in my opinion, we shouldn't change the default behavior, so we could consider this fixed when releasing that PR. Any strong opinion on this?
Activity
lordblendi commentedon Jan 30, 2019
Any update on this?
marcosmadr commentedon Feb 4, 2019
I investigated a bit this issue and I'm sharing what I've found so far.
Following there are two approaches to this problem:
Currently, if the date is incomplete and STRICT_PARSING is set, it keeps trying to parse the data using other formats, so we end up with different results depending on if you are using STRICT_PARSING or not.
Hey @asadurski , Could you give your opinion, if it's the right way to go?
nherger commentedon Feb 12, 2019
I'm having the exact same issue. Ideally, I would expect None to be returned when executing something like this:
dateparser.parse('2011', settings={'STRICT_PARSING': True})Are there any updates on this?
nvinchh commentedon Aug 26, 2019
Seeing this same issue. I personally think that without the date separators, an input of a number should return None if strict parsing has been set to true
Right now, I see this
`import sys
import dateparser
print(sys.version)
print(dateparser.version)
print("date = ", dateparser.parse('1024', settings={'STRICT_PARSING':True}))
print("date = ", dateparser.parse('March', settings={'STRICT_PARSING':True}))
print("date = ", dateparser.parse('1024823', settings={'STRICT_PARSING':True}))
`
With the output as:
3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] 0.7.1 date = 2010-02-04 00:00:00 date = None date = 4823-10-02 00:00:00I think both the first and third cases should return None
noviluni commentedon Sep 16, 2020
From my perspective, the
dateparser.parse()method should do the best to return dates.I know that
2017doesn't seem a full date, but it theoretically fits for 2020-01-07.I added a new PR separating the
no-spaces-timeparser from theabsolute-timeparser: #786It would allow doing:(and it wouldn't return anything).I know this doesn't fix the issue 100%, as you have to add specific settings, but in my opinion, we shouldn't change the default behavior, so we could consider this fixed when releasing that PR. Any strong opinion on this?noviluni commentedon Sep 21, 2020
Hi guys, we finally decided to exclude the
no-spaces-timeparser from the default parsers (PR: #786), so it will work as expected in the next version!