From e1f31e85ff6d6dab052049c2a4465659a791d844 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lafortune Date: Sat, 9 Jun 2018 13:32:38 -0400 Subject: Use fetch for better error handling --- .../lib/active_support/core_ext/date_and_time/calculations.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb index abe80a0786..c56e80fca2 100644 --- a/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_and_time/calculations.rb @@ -263,7 +263,7 @@ module DateAndTime # Week is assumed to start on +start_day+, default is # +Date.beginning_of_week+ or +config.beginning_of_week+ when set. def days_to_week_start(start_day = Date.beginning_of_week) - start_day_number = DAYS_INTO_WEEK[start_day] + start_day_number = DAYS_INTO_WEEK.fetch(start_day) (wday - start_day_number) % 7 end @@ -371,7 +371,7 @@ module DateAndTime end def days_span(day) - (DAYS_INTO_WEEK[day] - DAYS_INTO_WEEK[Date.beginning_of_week]) % 7 + (DAYS_INTO_WEEK.fetch(day) - DAYS_INTO_WEEK.fetch(Date.beginning_of_week)) % 7 end def copy_time_to(other) -- cgit v1.2.3