Skip to content

month/day format with time returns nil #114

Merged
merged 3 commits into from Sep 7, 2012

2 participants

@grantovich

This is related to #59, which I commented on but I guess it wasn't noticed. The issue is that month/day parsing (without a year) seems to always return nil when a time is given. For example:

irb> Chronic.parse('5/6')
=> 2012-05-06 12:00:00 -0400
irb> Chronic.parse('5/6/2012 at 12pm')
=> 2012-05-06 12:00:00 -0400
irb> Chronic.parse('5/6 at 12pm')
=> nil
@grantovich

The attached pull request fixes this issue and includes test cases for it.

@grantovich grantovich commented on the diff Sep 7, 2012
test/test_chronic.rb
@@ -67,6 +67,8 @@ def test_endian_definitions
# middle, little
endians = [
Chronic::Handler.new([:scalar_month, :separator_slash_or_dash, :scalar_day, :separator_slash_or_dash, :scalar_year, :separator_at?, 'time?'], :handle_sm_sd_sy),
+ Chronic::Handler.new([:scalar_month, :separator_slash_or_dash, :scalar_day, :separator_at?, 'time?'], :handle_sm_sd),
+ Chronic::Handler.new([:scalar_day, :separator_slash_or_dash, :scalar_month, :separator_at?, 'time?'], :handle_sd_sm),
Chronic::Handler.new([:scalar_day, :separator_slash_or_dash, :scalar_month, :separator_slash_or_dash, :scalar_year, :separator_at?, 'time?'], :handle_sd_sm_sy)
]
@grantovich
grantovich added a note Sep 7, 2012

I left this test as-is in the interest of separating changes, but I'm not sure why these lines and the following assert_equal are present. It's just testing that the endians array is equal to a copy-pasted copy of itself. Am I missing something here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@leejarvis
Collaborator

Yeah I must have missed your comment on that other issue. This looks great, thanks for the pull will merge this straight away.

@leejarvis leejarvis merged commit 201e2c3 into mojombo:master Sep 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.