Skip to content

Commit

Permalink
just spitballing on a fix here
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacronemeyer committed May 15, 2024
1 parent 3f010c0 commit aa07813
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/timecop/time_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ def parse_with_mock_date(*args)
)
when date_hash[:wday]
Date.closest_wday(date_hash[:wday]).to_datetime
when date_hash[:hour] && date_hash[:min] && date_hash[:sec]
DateTime.new(mocked_time_stack_item.year, mocked_time_stack_item.month, mocked_time_stack_item.day, date_hash[:hour], date_hash[:min], date_hash[:sec])
else
parsed_date + mocked_time_stack_item.travel_offset_days
end
Expand Down
4 changes: 4 additions & 0 deletions test/date_time_parse_scenarios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def test_date_time_parse_Date_10_slash_10
assert_equal DateTime.parse("2008-10-10"), DateTime.parse('Date 10/10')
end

def test_date_time_parse_time_only_scenario
assert_equal DateTime.parse("2008-09-01T15:00:00"), DateTime.parse('15:00:00')
end

def test_date_time_parse_month_year
assert_equal DateTime.parse("2012-12-01"), DateTime.parse('DEC 2012')
end
Expand Down

0 comments on commit aa07813

Please sign in to comment.