Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

GH #4883. Optional start_day argument for Time#all_week

  • Loading branch information...
commit b0374018c2f0b334c18ca80eb8ba94358f13e576 1 parent 2bf2055
Toshinori Kajihara kennyj authored
6 activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -273,9 +273,9 @@ def all_day
273 273 beginning_of_day..end_of_day
274 274 end
275 275
276   - # Returns a Range representing the whole week of the current time.
277   - def all_week
278   - beginning_of_week..end_of_week
  276 + # Returns a Range representing the whole week of the current time. Week starts on start_day (default is :monday, i.e. end of Sunday).
  277 + def all_week(start_day = :monday)
  278 + beginning_of_week(start_day)..end_of_week(start_day)
279 279 end
280 280
281 281 # Returns a Range representing the whole month of the current time.
1  activesupport/test/core_ext/time_ext_test.rb
@@ -802,6 +802,7 @@ def test_all_day
802 802
803 803 def test_all_week
804 804 assert_equal Time.local(2011,6,6,0,0,0)..Time.local(2011,6,12,23,59,59,999999.999), Time.local(2011,6,7,10,10,10).all_week
  805 + assert_equal Time.local(2011,6,5,0,0,0)..Time.local(2011,6,11,23,59,59,999999.999), Time.local(2011,6,7,10,10,10).all_week(:sunday)
805 806 end
806 807
807 808 def test_all_month

0 comments on commit b037401

Please sign in to comment.
Something went wrong with that request. Please try again.