From aa078132b22e65cd5cc84a90f82ee933f0068f0b Mon Sep 17 00:00:00 2001 From: Josh Cronemeyer Date: Fri, 29 Dec 2023 15:17:26 -0600 Subject: [PATCH] just spitballing on a fix here --- lib/timecop/time_extensions.rb | 2 ++ test/date_time_parse_scenarios.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/timecop/time_extensions.rb b/lib/timecop/time_extensions.rb index d3a0a4d..8d934cb 100644 --- a/lib/timecop/time_extensions.rb +++ b/lib/timecop/time_extensions.rb @@ -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 diff --git a/test/date_time_parse_scenarios.rb b/test/date_time_parse_scenarios.rb index 8af1a83..27941df 100644 --- a/test/date_time_parse_scenarios.rb +++ b/test/date_time_parse_scenarios.rb @@ -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