diff options
-rw-r--r-- | app/models/holiday.rb | 3 | ||||
-rw-r--r-- | spec/models/holiday_spec.rb | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/app/models/holiday.rb b/app/models/holiday.rb index f07e3b05e..490fdb8c7 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -62,6 +62,9 @@ class Holiday < ActiveRecord::Base # Calculate the date on which a request made on a given date falls due when # the days are given in calendar days (rather than working days) def Holiday.due_date_from_calendar_days(start_date, days) + # convert date/times into dates + start_date = start_date.to_date + response_required_by = start_date + days while weekend_or_holiday?(response_required_by) response_required_by += 1 diff --git a/spec/models/holiday_spec.rb b/spec/models/holiday_spec.rb index 45c301d67..30beacb50 100644 --- a/spec/models/holiday_spec.rb +++ b/spec/models/holiday_spec.rb @@ -77,6 +77,10 @@ describe Holiday, " when calculating due date" do it "handles the due date falling on a Holiday" do Holiday.due_date_from_calendar_days(Date.new(2008, 12, 5), 20).should == Date.new(2008, 12, 29) end + + it "handles Time objects" do + Holiday.due_date_from_calendar_days(Time.utc(2009, 03, 17, 12, 0, 0), 20).should == Date.new(2009, 4, 6) + end end end |