Skip to content

Commit

Permalink
Adds 2021 holidays and tests against GOV.UK. Relates to NHSDigital#8
Browse files Browse the repository at this point in the history
  • Loading branch information
timgentry committed Dec 10, 2019
1 parent 4a26fe1 commit 70a1026
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/ndr_support/concerns/working_days.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ module WorkingDays
'2020-08-31', # Monday - Summer bank holiday
'2020-12-25', # Friday - Christmas Day
'2020-12-28', # Monday - Boxing Day (substitute day)
# 2021
'2021-01-01', # Friday - New Year’s Day
'2021-04-02', # Friday - Good Friday
'2021-04-05', # Monday - Easter Monday
'2021-05-03', # Monday - Early May bank holiday
'2021-05-31', # Monday - Spring bank holiday
'2021-08-30', # Monday - Summer bank holiday
'2021-12-27', # Monday - Christmas Day
'2021-12-28', # Tuesday - Boxing Day
].map { |str| Date.parse(str) }

def self.check_lookup
Expand Down
18 changes: 18 additions & 0 deletions test/concerns/working_days_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,22 @@ def setup
assert_equal 253, @normal_time.working_days_until(@normal_time + 1.year)
assert_equal 253, @normal_date_time.working_days_until(@normal_date_time + 1.year)
end

test 'against GOV.UK holidays' do
require 'net/http'
require 'json'

url = 'https://www.gov.uk/bank-holidays/england-and-wales.json'
response = Net::HTTP.get(URI(url))

events = JSON.parse(response)['events']
events.each do |event|
event_date = event['date']
parsed_date = Date.parse(event_date)

assert parsed_date.public_holiday?, "#{event_date} should be a public holiday"
# next if parsed_date.public_holiday?
# puts "'#{event_date}', # #{parsed_date.strftime('%A')} - #{event['title']}"
end
end
end

0 comments on commit 70a1026

Please sign in to comment.