Class: TZInfo::LastDayOfMonthTransitionRule Private
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 last occurrence of a particular day of week of a calendar month.
Class Method Summary
-
.new(month, day_of_week, transition_at = 0) ⇒ LastDayOfMonthTransitionRule
constructor
Internal use only
Initializes a new
LastDayOfMonthTransitionRule
.
DayOfWeekTransitionRule
- Inherited
.new | Initializes a new |
TransitionRule
- Inherited
.new | Initializes a new |
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
-
#==(r) ⇒ Boolean
(also: #eql?)
Internal use only
Determines if this
LastDayOfMonthTransitionRule
is equal to another instance. -
#eql?(r)
Alias for #==.
-
#get_day(offset, year) ⇒ Time
protected
Internal use only
Returns a
Time
representing midnight local time on the day specified by the rule for the given offset and year.
DayOfWeekTransitionRule
- Inherited
#== | Determines if this |
#eql? | Alias for DayOfWeekTransitionRule#==. |
#hash_args |
TransitionRule
- Inherited
#== | Determines if this |
#at | Calculates the time of the transition from a given offset on a given year. |
#eql? | Alias for TransitionRule#==. |
#hash, #hash_args |
Instance Method Details
#==(r) ⇒ Boolean
Also known as: #eql?
Determines if this LastDayOfMonthTransitionRule
is equal to another
instance.
# File 'lib/tzinfo/transition_rule.rb', line 420
def ==(r) super(r) && r.kind_of?(LastDayOfMonthTransitionRule) end
#eql?(r)
Alias for #==.
# File 'lib/tzinfo/transition_rule.rb', line 423
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.
# File 'lib/tzinfo/transition_rule.rb', line 435
def get_day(offset, year) next_month = month + 1 if next_month == 13 year += 1 next_month = 1 end candidate = Time.new(year, next_month, 1, 0, 0, 0, offset.observed_utc_offset) - 86400 diff = candidate.wday - day_of_week if diff < 0 candidate - (diff + 7) * 86400 elsif diff > 0 candidate - diff * 86400 else candidate end end