Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacronemeyer committed Aug 12, 2023
1 parent 9dc096a commit aa555f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/timecop/time_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def strptime_with_mock_date(str = '-4712-01-01', fmt = '%F', start = Date::ITALY
now = Time.now.to_date
year = d[:year] || now.year
mon = d[:mon] || now.mon
leftover = d[:leftover] || 0
if d.keys == [:year]
the_date = if d.keys == [:year]
Date.new(year, 1, 1, start)
elsif d[:mday]
Date.new(year, mon, d[:mday], start)
Expand All @@ -68,8 +67,7 @@ def strptime_with_mock_date(str = '-4712-01-01', fmt = '%F', start = Date::ITALY
Date.commercial(d[:cwyear], d[:cweek], 1, start)
end
elsif d[:wnum1]
fraction_of_a_day = Rational(leftover, 60*60*24)
Date.commercial(year, d[:wnum1], 1, start) + fraction_of_a_day
Date.commercial(year, d[:wnum1], 1, start)
elsif d[:seconds]
Time.at(d[:seconds]).to_date
else
Expand Down
1 change: 1 addition & 0 deletions test/date_strptime_scenarios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_date_strptime_without_specifying_format
def test_date_strptime_with_day_of_week
assert_equal Date.strptime('Thursday', '%A'), Date.new(1984, 3, 1)
assert_equal Date.strptime('Monday', '%A'), Date.new(1984, 2, 27)
assert_equal Date.strptime('Monday', '%A'), Date.new(1984, 2, 27)
end

def test_date_strptime_with_commercial_week_date
Expand Down

0 comments on commit aa555f9

Please sign in to comment.