aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2018-06-09 13:32:38 -0400
committerMarc-Andre Lafortune <github@marc-andre.ca>2018-06-09 13:47:03 -0400
commite1f31e85ff6d6dab052049c2a4465659a791d844 (patch)
treedc22fa4ced15132d69480c6368318ef8bec37165 /activesupport
parentdd7f8ca3cd18086b012715ba88fc2fb9f153c9ac (diff)
downloadrails-e1f31e85ff6d6dab052049c2a4465659a791d844.tar.gz
rails-e1f31e85ff6d6dab052049c2a4465659a791d844.tar.bz2
rails-e1f31e85ff6d6dab052049c2a4465659a791d844.zip
Use fetch for better error handling
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/date_and_time/calculations.rb4
1 files 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)