Skip to content

Commit

Permalink
GH rails#4883. Optional start_day argument for Time#all_week
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyj committed Feb 5, 2012
1 parent 2bf2055 commit b037401
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -273,9 +273,9 @@ def all_day
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.
Expand Down
1 change: 1 addition & 0 deletions activesupport/test/core_ext/time_ext_test.rb
Expand Up @@ -802,6 +802,7 @@ def test_all_day

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
Expand Down

0 comments on commit b037401

Please sign in to comment.