diff options
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 62 |
1 files changed, 5 insertions, 57 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 69e7a8408..e1e6ba4f3 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -23,7 +23,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.175 2009-03-09 15:48:32 tony Exp $ +# $Id: info_request.rb,v 1.176 2009-03-09 17:13:07 tony Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -457,62 +457,10 @@ public return due_date_for_request_date(last_sent.outgoing_message.last_sent_at) end - # This needs extracted to somewhere else; it's too generic to live here, - # and isn't really an instance method as just expects to be passed a date - # I don't really know where/how though (TB 2009-03-06) + # TODO move this into Holiday class def due_date_for_request_date(request_date) - holidays = { - # Union of holidays from these places: - # http://www.direct.gov.uk/en/Governmentcitizensandrights/LivingintheUK/DG_073741 - # http://www.dti.gov.uk/employment/bank-public-holidays/ - # http://www.scotland.gov.uk/Publications/2005/01/bankholidays - - '2007-11-30' => "St. Andrew's Day", - '2007-12-25' => "Christmas Day", - '2007-12-26' => "Boxing Day", - - '2008-01-01' => "New Year's Day", - '2008-01-02' => "2nd January (Scotland)", - '2008-03-17' => "St. Patrick's Day (NI)", - '2008-03-21' => "Good Friday", - '2008-03-24' => "Easter Monday", - '2008-05-05' => "Early May Bank Holiday", - '2008-05-26' => "Spring Bank Holiday", - '2008-07-14' => "Battle of the Boyne (NI)", - '2008-08-04' => "Summer Bank Holiday (Scotland)", - '2008-08-25' => "Summer Bank Holiday (England + Wales)", - '2008-12-01' => "St. Andrew's Day (Scotland)", - '2008-12-25' => "Christmas Day", - '2008-12-26' => "Boxing Day", - - '2009-01-01' => "New Year's Day", - '2009-01-02' => "2nd January (Scotland)", - '2009-03-17' => "St. Patrick's Day (NI)", - '2009-04-10' => "Good Friday", - '2009-04-13' => "Easter Monday", - '2009-05-04' => "Early May Bank Holiday", - '2009-05-25' => "Spring Bank Holiday", - '2009-07-13' => "Battle of the Boyne (NI)", - '2009-08-03' => "Summer Bank Holiday (Scotland)", - '2009-08-31' => "Summer Bank Holiday (England + Wales)", - '2009-11-30' => "St. Andrew's Day (Scotland)", - '2009-12-25' => "Christmas Day", - '2009-12-28' => "Boxing Day", - - '2010-01-01' => "New Year's Day", - '2010-01-04' => "2nd January (Scotland)", - '2010-03-17' => "St. Patrick's Day (NI)", - '2010-04-02' => "Good Friday", - '2010-04-05' => "Easter Monday", - '2010-05-03' => "Early May Bank Holiday", - '2010-05-31' => "Spring Bank Holiday", - '2010-07-12' => "Battle of the Boyne (NI)", - '2010-08-02' => "Summer Bank Holiday (Scotland)", - '2010-08-30' => "Summer Bank Holiday (England + Wales)", - '2010-11-30' => "St. Andrew's Day (Scotland)", - '2010-12-27' => "Christmas Day", - '2010-12-28' => "Boxing Day" - } + # TODO only fetch holidays after the request_date + holidays = Holiday.all.collect { |h| h.day }.to_set # Count forward 20 working days. We start with today (or if not a working day, # the next working day*) as "day zero". The first of the twenty full @@ -530,7 +478,7 @@ public while days_passed < 20 response_required_by += 1.day next if response_required_by.wday == 0 || response_required_by.wday == 6 # weekend - next if holidays.include?(response_required_by.strftime('%Y-%m-%d')) # holiday + next if holidays.include?(response_required_by) days_passed += 1 end |