parliament-calendar.herokuapp.com

 1 module CALCULATION_COMMONS_ONLY_SI

A method for calculating the end date of a scrutiny period, based on days on which the House of Commons must be sitting or on a short adjournment. This method is used for Commons only negative Statutory Instruments as set out by the Statutory Instruments Act 1946 and for made affirmative Statutory Instruments as set out by their enabling Act.

The calculation counts in actual sitting days, requiring the start date and the number of days to count.

The calculation is defined by paragraphs 1 and 2 of Section 7 of the Statutory Instruments Act 1946, though a different calculation may be required if the instrument is laid under another Act - as per paragraph 3.

 6   def commons_only_si_calculation(date, target_day_count)

We start counting on the first day the House of Commons has a scrutiny day.

For negative Statutory Instruments this will be the day on which the instrument was laid, if that day was a scrutiny day. For made negative Statutory Instruments, this is defined by the Statutory Instruments Act 1946 Section 5 paragraph 1. For draft negative Statutory Instruments, this is defined by the Statutory Instruments Act 1946 Section 6 paragraph 1.

For made affirmatives this will be the day on which the instrument was made, if that day was a scrutiny day.

If the laying day - or making day for a made affirmative instrument - is a House of Commons scrutiny day we don't have to cycle through the calendar to find a subsequent one ...

 11     if date.is_commons_scrutiny_day?

... and the laying or making day is the start of the scrutiny period.

 14       @scrutiny_start_date = date

Otherwise, the laying or making day is not a House of Commons scrutiny day, then ...

 17     else

... if there is a future House of Commons scrutiny day ...

 20       if date.first_commons_scrutiny_day

... we set the date to that day. In practice this will be the first sitting day following the laying.

 23         date = date.first_commons_scrutiny_day

... we have found the start of the scrutiny period.

 26         @scrutiny_start_date = date

If we didn't find a future House of Commons scrutiny day in our calendar, we can't calculate the scrutiny period, ...

 29       else

... this error message is displayed ...

 32         @error_message = "Unable to find a future House of Commons sitting day. It's not currently possible to calculate an anticipated end date, as the likely end date occurs during a period for which sitting days are yet to be announced."

... and we stop looking for a scrutiny period end date.

 35         return
 36       end
 37     end

We've found the first House of Commons scrutiny day so we start counting from day 1.

 40     day_count = 1

Whilst the number of days we’re counting is less than the target number of days to count ...

 43     while day_count < target_day_count

... continue to the next day.

 46       date = date.next_day

... and add 1 to the day count if this is a House of Commons scrutiny day.

 49       day_count += 1 if date.is_commons_scrutiny_day?

... if the calendar has no record of what type of day this is, we can't calculate the end date, ...

 52       next unless date.is_calendar_not_populated?

... this error message is displayed to users ...

 55       @error_message = "It's not currently possible to calculate an anticipated end date, as the likely end date occurs during a period for which sitting days are yet to be announced."

... and we stop looking through the calendar.

 58       break
 59     end

Return the anticipated end date of the scrutiny period for display.

 62     date
 63   end
 64 end