1 module CALCULATION_INTERVAL
We pass the start and end dates of the interval.
6 def calculate_sitting_days_in_interval( start_date, end_date )
We set the date to start counting from to the start date.
9 date = @start_date
Whilst the date is not later than the end date ...
12 while date <= @end_date
If the date is a Commons sitting day ...
15 if date.is_commons_actual_sitting_day?
... we increment the Commons sitting day count.
18 @commons_sitting_day_count += 1
19 end
If the date is a Lords sitting day ...
22 if date.is_lords_actual_sitting_day?
... we increment the Lords sitting day count.
25 @lords_sitting_day_count += 1
26 end
We continue to the next day.
29 date = date.next_day
30 end
31 end
32 end