Skip to content

Commit

Permalink
Added case when wday and hour/minute exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrela authored and joshuacronemeyer committed May 15, 2024
1 parent d62a307 commit 34cde98
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/timecop/time_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ def parse_with_mock_date(*args)
DateTime.new(mocked_time_stack_item.year, date_hash[:mon], date_hash[:mday])
when date_hash[:mday]
DateTime.new(mocked_time_stack_item.year, mocked_time_stack_item.month, date_hash[:mday])
when date_hash[:wday] && date_hash[:hour] && date_hash[:min]
closest_date = Date.closest_wday(date_hash[:wday]).to_datetime

DateTime.new(
closest_date.year, closest_date.month, closest_date.day,
date_hash[:hour], date_hash[:min]
)
when date_hash[:wday]
Date.closest_wday(date_hash[:wday]).to_datetime
else
Expand Down

0 comments on commit 34cde98

Please sign in to comment.