instance method days_to_week_start

Ruby on Rails 3.2.22.5

Since v3.2.22.5 Last seen in v3.2.22.5

Signature

days_to_week_start(start_day = :monday)

Returns number of days to start of this week. Week is assumed to start on start_day, default is :monday.

Parameters

start_day opt = :monday
Source
# File activesupport/lib/active_support/core_ext/date/calculations.rb, line 179
  def days_to_week_start(start_day = :monday)
    start_day_number = DAYS_INTO_WEEK[start_day]
    current_day_number = wday != 0 ? wday - 1 : 6
    (current_day_number - start_day_number) % 7
  end

Defined in activesupport/lib/active_support/core_ext/date/calculations.rb line 179 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Date

Type at least 2 characters to search.

↑↓ navigate · open · esc close