1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #4891 from kennyj/fix_4883

[master] Optional start_day argument for Time#all_week.
This commit is contained in:
Santiago Pastorino 2012-02-05 07:25:50 -08:00
commit 09804fb704
2 changed files with 4 additions and 3 deletions

View file

@ -273,9 +273,9 @@ class Time
beginning_of_day..end_of_day
end
# Returns a Range representing the whole week of the current time.
def all_week
beginning_of_week..end_of_week
# Returns a Range representing the whole week of the current time. Week starts on start_day (default is :monday, i.e. end of Sunday).
def all_week(start_day = :monday)
beginning_of_week(start_day)..end_of_week(start_day)
end
# Returns a Range representing the whole month of the current time.

View file

@ -807,6 +807,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
def test_all_week
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
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)
end
def test_all_month