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

dayfirst=True seems not to be honoured when trying to parse dates in format ddmmyyyy #1163

Open
jmartens opened this issue Aug 17, 2021 · 2 comments · May be fixed by #1164 or #1296
Open

dayfirst=True seems not to be honoured when trying to parse dates in format ddmmyyyy #1163

jmartens opened this issue Aug 17, 2021 · 2 comments · May be fixed by #1164 or #1296

Comments

@jmartens
Copy link

jmartens commented Aug 17, 2021

When trying to parse a datetime with the ddmmyyyy format it seems to parse differently than when dashes are used as separators, even when dayFirst is set to True:

for dt in ['22-04-2011', '22042011']:
    print(parse(dt, dayfirst=True)) 
    
2011-04-22 00:00:00
2204-11-20 00:00:00

I would have expected the first result in both cases.

jmartens added a commit to jmartens/dateutil that referenced this issue Aug 17, 2021
Honour dayfirst option when parsing dates in format ddmmyyy

refs dateutil#1163
jmartens added a commit to jmartens/dateutil that referenced this issue Aug 17, 2021
Honour dayfirst option when parsing dates in format ddmmyyy

refs dateutil#1163
@jmartens
Copy link
Author

I think I have been able to chase this down to info.dayfirst not being honoured at

elif len_li in (8, 12, 14):
# YYYYMMDD
s = tokens[idx]
ymd.append(s[:4], 'Y')
ymd.append(s[4:6])
ymd.append(s[6:8])

The year seems to be taken from the first characters of the token anyhow, where I would expect that this only happens when info.yearfirst=True, not when info.dayfirst=True.

@jmartens
Copy link
Author

For referece:

# python -c "import dateutil; print(dateutil.__version__)"
2.8.2
# python --version
Python 3.9.6

@jmartens jmartens linked a pull request Aug 17, 2021 that will close this issue
3 tasks
@nicoe nicoe linked a pull request Jul 12, 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
Labels
None yet
Projects
None yet
1 participant