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

Always match "endian" formats first? #58

Closed
jcbpl opened this issue Jul 28, 2011 · 0 comments
Closed

Always match "endian" formats first? #58

jcbpl opened this issue Jul 28, 2011 · 0 comments

Comments

@jcbpl
Copy link

jcbpl commented Jul 28, 2011

I might be missing something obvious, but I think it's really strange that "7/12/11" parses to 2007-12-11 while "7/13/11" parses to 2011-07-13.

ruby-1.9.2-p290 :011 > Chronic.parse("7/12/11")
+---------------------------------------------------
| [7(repeater-time-25200?, scalar, scalar-day-7, scalar-month-7, scalar-year-2007) , /(separator-slashordash-slash) , 12(repeater-time-0?, scalar, scalar-day-12, scalar-month-12, scalar-year-2012) , /(separator-slashordash-slash) , 11(repeater-time-39600?, scalar, scalar-day-11, scalar-month-11, scalar-year-2011) ]
+---------------------------------------------------
-date
Handler: handle_sy_sm_sd
 => 2007-12-11 12:00:00 -0500 
ruby-1.9.2-p290 :012 > Chronic.parse("7/13/11")
+---------------------------------------------------
| [7(repeater-time-25200?, scalar, scalar-day-7, scalar-month-7, scalar-year-2007) , /(separator-slashordash-slash) , 13(repeater-time-46800?, scalar, scalar-day-13, scalar-year-2013) , /(separator-slashordash-slash) , 11(repeater-time-39600?, scalar, scalar-day-11, scalar-month-11, scalar-year-2011) ]
+---------------------------------------------------
-date
Handler: handle_sm_sd_sy
 => 2011-07-13 12:00:00 -0400

Because 12 could be a month, Chronic matches handle_sy_sm_sd instead of handle_sm_sd_sy, which is what the second date matches. I would expect that it would always match the second, unless the first part of the date is four digits (i.e. 2007/12/11), so this seems like a bug to me.

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