Skip to content

Commit

Permalink
fixed issue when dealing with dates without given year, that lays in …
Browse files Browse the repository at this point in the history
…past (should become dates with next year)
  • Loading branch information
synopia committed Apr 7, 2014
1 parent f4dce94 commit 1ea8248
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/chronic/handlers.rb
Expand Up @@ -8,6 +8,7 @@ def handle_m_d(month, day, time_tokens, options)
span = month.this(options[:context])
year, month = span.begin.year, span.begin.month
day_start = Chronic.time_class.local(year, month, day)
day_start = Chronic.time_class.local(year + 1, month, day) if options[:context] == :future && day_start < now

day_or_time(day_start, time_tokens, options)
end
Expand Down
6 changes: 3 additions & 3 deletions test/test_parsing.rb
Expand Up @@ -41,13 +41,13 @@ def test_handle_generic

def test_handle_rmn_sd
time = parse_now("aug 3")
assert_equal Time.local(2006, 8, 3, 12), time
assert_equal Time.local(2007, 8, 3, 12), time

time = parse_now("aug 3", :context => :past)
assert_equal Time.local(2006, 8, 3, 12), time

time = parse_now("aug. 3")
assert_equal Time.local(2006, 8, 3, 12), time
assert_equal Time.local(2007, 8, 3, 12), time

time = parse_now("aug 20")
assert_equal Time.local(2006, 8, 20, 12), time
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_handle_rmn_od

def test_handle_od_rm
time = parse_now("fifteenth of this month")
assert_equal Time.local(2006, 8, 15, 12), time
assert_equal Time.local(2007, 8, 15, 12), time
end

def test_handle_od_rmn
Expand Down

0 comments on commit 1ea8248

Please sign in to comment.