class TZInfo::DayOfMonthTransitionRule

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/tzinfo/transition_rule.rbs

class TZInfo::DayOfMonthTransitionRule < TZInfo::DayOfWeekTransitionRule
  def get_day: (TZInfo::TimezoneOffset offset, Integer year) -> Time
end

:nodoc:
@private
of a calendar month.
A rule that transitions on the nth occurrence of a particular day of week

def ==(r)

Returns:
  • (Boolean) - `true` if `r` is a {DayOfMonthTransitionRule} with the

Parameters:
  • r (Object) -- the instance to test for equality.
def ==(r)
  super(r) && r.kind_of?(DayOfMonthTransitionRule) && @offset_start == r.offset_start
end

def get_day(offset, year)

Experimental RBS support (using type sampling data from the type_fusion project).

def get_day: (TZInfo::TimezoneOffset offset, Integer year) -> Time

This signature was generated using 2 samples from 1 application.

Returns:
  • (Time) - midnight local time on the day specified by the rule for

Parameters:
  • year (Integer) -- the year in which the transition occurs.
  • offset (TimezoneOffset) -- the current offset at the time of the
def get_day(offset, year)
  candidate = Time.new(year, month, @offset_start, 0, 0, 0, offset.observed_utc_offset)
  diff = day_of_week - candidate.wday
  if diff < 0
    candidate + (7 + diff) * 86400
  elsif diff > 0
    candidate + diff * 86400
  else
    candidate
  end
end

def hash_args

(see TransitionRule#hash_args)
def hash_args
  [@offset_start] + super
end

def initialize(month, week, day_of_week, transition_at = 0)

Raises:
  • (ArgumentError) - if `day_of_week` is less than 0 or greater than 6.
  • (ArgumentError) - if `day_of_week` is not an `Integer`.
  • (ArgumentError) - if `week` is less than 1 or greater than 4.
  • (ArgumentError) - if `week` is not an `Integer`.
  • (ArgumentError) - if `month` is less than 1 or greater than 12.
  • (ArgumentError) - if `month` is not an `Integer`.
  • (ArgumentError) - if `transition_at` is not an `Integer`.

Parameters:
  • transition_at (Integer) -- the time in seconds after midnight local
  • day_of_week (Integer) -- the day of the week when the transition
  • week (Integer) -- the week of the month when the transition occurs (1
  • month (Integer) -- the month of the year when the transition occurs.

Other tags:
    Private: -
def initialize(month, week, day_of_week, transition_at = 0)
  super(month, day_of_week, transition_at)
  raise ArgumentError, 'Invalid week' unless week.kind_of?(Integer) && week >= 1 && week <= 4
  @offset_start = (week - 1) * 7 + 1
end