123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::DayOfMonthTransitionRule Private

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: TZInfo::DayOfWeekTransitionRule
Defined in: lib/tzinfo/transition_rule.rb

Overview

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

Class Method Summary

DayOfWeekTransitionRule - Inherited

.new

Initializes a new DayOfWeekTransitionRule.

TransitionRule - Inherited

.new

Initializes a new TransitionRule.

Instance Attribute Summary

DayOfWeekTransitionRule - Inherited

TransitionRule - Inherited

#transition_at

Returns the number of seconds after midnight local time on the day identified by the rule at which the transition occurs.

Instance Method Summary

DayOfWeekTransitionRule - Inherited

#==

Determines if this DayOfWeekTransitionRule is equal to another instance.

#eql?
#hash_args

TransitionRule - Inherited

#==

Determines if this TransitionRule is equal to another instance.

#at

Calculates the time of the transition from a given offset on a given year.

#eql?
#hash, #hash_args

Instance Attribute Details

#offset_startInteger (readonly, protected)

Returns:

  • (Integer)

    the day the week starts on for a month starting on a Sunday.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 362

attr_reader :offset_start

Instance Method Details

#==(r) ⇒ Boolean Also known as: #eql?

Determines if this DayOfMonthTransitionRule is equal to another instance.

Parameters:

  • r (Object)

    the instance to test for equality.

Returns:

  • (Boolean)

    true if r is a DayOfMonthTransitionRule with the same transition_at, month, week and day of week as this DayOfMonthTransitionRule, otherwise false.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 353

def ==(r)
  super(r) && r.kind_of?(DayOfMonthTransitionRule) && @offset_start == r.offset_start
end

#eql?(r)

Alias for #==.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 356

alias eql? ==

#get_day(offset, year) ⇒ Time (protected)

Returns a Time representing midnight local time on the day specified by the rule for the given offset and year.

Parameters:

  • offset (TimezoneOffset)

    the current offset at the time of the transition.

  • year (Integer)

    the year in which the transition occurs.

Returns:

  • (Time)

    midnight local time on the day specified by the rule for the given offset and year.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 372

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

#hash_argsArray (protected)

Returns:

  • (Array)

    an Array of parameters that will influence the output of hash.

[ GitHub ]

  
# File 'lib/tzinfo/transition_rule.rb', line 386

def hash_args
  [@offset_start] + super
end