123456789_123456789_123456789_123456789_123456789_

Class: TZInfo::JulianDayOfYearTransitionRule 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::DayOfYearTransitionRule
Defined in: lib/tzinfo/transition_rule.rb

Overview

Defines transitions that occur on the one-based nth Julian day of the year.

Leap days are not counted. Day 1 is 1 January. Day 60 is always 1 March. Day 365 is always 31 December.

Constant Summary

Class Method Summary

DayOfYearTransitionRule - Inherited

.new

Initializes a new DayOfYearTransitionRule.

TransitionRule - Inherited

.new

Initializes a new TransitionRule.

Instance Attribute Summary

DayOfYearTransitionRule - 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

DayOfYearTransitionRule - Inherited

#==

Determines if this DayOfYearTransitionRule 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

#is_always_first_day_of_year?Boolean (readonly)

Returns:

  • (Boolean)

    true if the day specified by this transition is the first in the year (a day number of 1), otherwise false.

[ GitHub ]

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

def is_always_first_day_of_year?
  seconds == 86400
end

#is_always_last_day_of_year?Boolean (readonly)

Returns:

  • (Boolean)

    true if the day specified by this transition is the last in the year (a day number of 365), otherwise false.

[ GitHub ]

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

def is_always_last_day_of_year?
  seconds == YEAR
end

Instance Method Details

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

Determines if this JulianDayOfYearTransitionRule is equal to another instance.

Parameters:

  • r (Object)

    the instance to test for equality.

Returns:

  • (Boolean)

    true if r is a JulianDayOfYearTransitionRule with the same transition_at and day as this JulianDayOfYearTransitionRule, otherwise false.

[ GitHub ]

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

def ==(r)
  super(r) && r.kind_of?(JulianDayOfYearTransitionRule)
end

#eql?(r)

Alias for #==.

[ GitHub ]

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

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 241

def get_day(offset, year)
  # Returns 1 March on non-leap years.
  leap = Time.new(year, 2, 29, 0, 0, 0, offset.observed_utc_offset)
  diff = seconds - LEAP
  diff += 86400 if diff >= 0 && leap.mday == 29
  leap + diff
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 250

def hash_args
  [JulianDayOfYearTransitionRule] + super
end