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

Year is parsed wrongly if the date is of format MMM DD, YYxx xx:SS #137

Closed
codereverser opened this issue Nov 2, 2015 · 2 comments
Closed
Labels

Comments

@codereverser
Copy link

With the current version of parsedatetime,

import parsedatetime as pdt
import time

cal = pdt.Calendar()

def parsed_time(time_str):
    # Just prints the parsed time back
    return time.strftime('%Y-%m-%d %H:%M', cal.parse(time_str)[0])

times = ['Aug 05, 2014 4:15 AM', 'Aug 05, 2003 3:15 AM', 'Aug 05, 2003 03:15 AM']
for t in times:
    print '{}\t{}'.format(t, parsed_time(t))

returns

Aug 05, 2014 4:15 AM    2016-08-05 04:15
Aug 05, 2003 3:15 AM    2016-08-05 03:15
Aug 05, 2003 03:15 AM   2020-08-05 03:15

PS:- I guess the bug is in function _partialParseDateStr where there has to be an additional check if the matched time is indeed inside parseStr

say changing

if fTime:

to

if fTime and len(parseStr) > mm.start('hours'):

seems to be working for me.

@philiptzou philiptzou added the bug label Nov 2, 2015
philiptzou added a commit to philiptzou/parsedatetime that referenced this issue Nov 2, 2015
but not strict char position

Which cause certain strings with format like "MM DD, YYxx xx:SS" parsed
incorrectly.

See detail: bear#137
philiptzou added a commit to philiptzou/parsedatetime that referenced this issue Nov 2, 2015
…t char position

Which cause certain strings with format like "MM DD, YYxx xx:SS" parsed
incorrectly.

See bear#137
@philiptzou
Copy link
Collaborator

@codereverser Please check if this bug has been fixed.

@codereverser
Copy link
Author

Looks all good now. Many thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants