Closed Kiruthikaaarthi closed 2 years ago
@sisyphsu , We have a fix for this and created a PR for the same: https://github.com/sisyphsu/dateparser/pull/25 Can you please review this?
Thanks in advance, Kiruthika
Thanks for your PR.
I have merged it into 1.0.10
version
Thanks @sisyphsu ! :)
Hi ,
While using DateParser lib for en_US language, where it considers month first, it works as expected if we provide any values within 12 for month. Example: 09/21/2021. But when we provide greater than 12( example, 17/03/2021), it is behaving a bit different. From my understanding from document, it should not consider a preferMonthFirst if it is greater than 12. So, expected date in this case is March 17, 2021. But it displays, May 3, 2022.
Case 1: prefer date first: In the below example, when we provided the month greater than 12, it prefers first value as a month. This is expected and correct behaviour
dateParser.setPreferMonthFirst(false); dateParser.parseDate("12/17/21") Result: Date@64 "Fri Dec 17 00:00:00 IST 2021"
Case 2: prefer month first: In the below example, when we provide month greater than 12, it ideally should reset to prefer date first.
dateParser.setPreferMonthFirst(true); dateParser.parseDate("17/09/2021") Result: Date@72 "Mon May 09 00:00:00 IST 2022" Expected Value: : Mon Sept 17 00:00:00 IST 2021
Not sure why the behaviour is like this. We would also expect it to parse without considering preferMonthFirst.
Could you please help us here on how we can handle this so that we get date as first prefered only in this edge case?