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

Bug: "2015-01-01" is parsed as the current date. #133

Closed
flight16 opened this issue Oct 19, 2015 · 1 comment
Closed

Bug: "2015-01-01" is parsed as the current date. #133

flight16 opened this issue Oct 19, 2015 · 1 comment

Comments

@flight16
Copy link

Reproducer script:

import parsedatetime 
str_in="2015-01-01"
cal = parsedatetime.Calendar()
dt_out = cal.parseDT(datetimeString=str_in)[0]
str_out = dt_out.strftime("%Y-%m-%d")
print("in={0}, out={1}".format(str_in, str_out))

Output:

in=2015-01-01, out=2015-10-19

In my case I'm parsing "YYYY-MM-DD HH:MM" strings.

@idpaterson
Copy link
Collaborator

This is working in the latest master branch; the referenced fix has not yet been released but it is possible to parse both the date and time in that format. Version 2.0 is in progress, until then I recommend using the master branch to pick up a lot of fixes from the past few months.

>>> import parsedatetime 
>>> str_in="2015-01-01 05:30"
>>> cal = parsedatetime.Calendar()
>>> dt_out = cal.parseDT(datetimeString=str_in)[0]
>>> str_out = dt_out.strftime("%Y-%m-%d %H:%M:%S")
>>> print("in={0}, out={1}".format(str_in, str_out))
in=2015-01-01 05:30, out=2015-01-01 05:30:00

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