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

just spitballing on a fix here #415

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/timecop/time_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def parse_with_mock_date(*args)
DateTime.new(mocked_time_stack_item.year, mocked_time_stack_item.month, date_hash[:mday])
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