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 starts on start_day (default is :monday).

Parameters

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

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

Defined in Time

Type at least 2 characters to search.

↑↓ navigate · open · esc close