Class TZInfo::TimezonePeriod
In: vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb
Parent: Object

A period of time in a timezone where the same offset from UTC applies.

All the methods that take times accept instances of Time, DateTime or integer timestamps.

Methods

Attributes

end_transition  [R]  The TimezoneTransitionInfo that defines the end of this TimezonePeriod (may be nil if unbounded).
offset  [R]  The TimezoneOffsetInfo for this period.
start_transition  [R]  The TimezoneTransitionInfo that defines the start of this TimezonePeriod (may be nil if unbounded).

Public Class methods

Initializes a new TimezonePeriod.

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 44
44:     def initialize(start_transition, end_transition, offset = nil)
45:       @start_transition = start_transition
46:       @end_transition = end_transition
47:       
48:       if offset
49:         raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition
50:         @offset = offset
51:       else
52:         if @start_transition 
53:           @offset = @start_transition.offset
54:         elsif @end_transition
55:           @offset = @end_transition.previous_offset
56:         else
57:           raise ArgumentError, 'No offset specified and no transitions to determine it from'
58:         end
59:       end
60:       
61:       @utc_total_offset_rational = nil      
62:     end

Public Instance methods

Returns true if this TimezonePeriod is equal to p. This compares the start_transition, end_transition and offset using ==.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 170
170:     def ==(p)
171:       p.respond_to?(:start_transition) && p.respond_to?(:end_transition) &&
172:         p.respond_to?(:offset) && start_transition == p.start_transition &&
173:         end_transition == p.end_transition && offset == p.offset
174:     end

The identifier of this period, e.g. "GMT" (Greenwich Mean Time) or "BST" (British Summer Time) for "Europe/London". The returned identifier is a symbol.

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 79
79:     def abbreviation
80:       @offset.abbreviation
81:     end

true if daylight savings is in effect for this period; otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 120
120:     def dst?
121:       @offset.dst?
122:     end

Returns true if this TimezonePeriods is equal to p. This compares the start_transition, end_transition and offset using eql?

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 178
178:     def eql?(p)
179:       p.respond_to?(:start_transition) && p.respond_to?(:end_transition) &&
180:         p.respond_to?(:offset) && start_transition.eql?(p.start_transition) &&
181:         end_transition.eql?(p.end_transition) && offset.eql?(p.offset)
182:     end

Returns a hash of this TimezonePeriod.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 185
185:     def hash
186:       result = @start_transition.hash ^ @end_transition.hash
187:       result ^= @offset.hash unless @start_transition || @end_transition
188:       result       
189:     end

Returns internal object state as a programmer-readable string.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 192
192:     def inspect
193:       result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}"
194:       result << ",#{@offset.inspect}>" unless @start_transition || @end_transition
195:       result + '>'
196:     end

true if the given local DateTime is after the start of the period (inclusive); otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 148
148:     def local_after_start?(local)
149:       !@start_transition || @start_transition.local_start <= local
150:     end

true if the given local DateTime is before the end of the period (exclusive); otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 154
154:     def local_before_end?(local)
155:       !@end_transition || @end_transition.local_end > local
156:     end

The end time of the period in local time as a DateTime. May be nil if unbounded.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 115
115:     def local_end
116:       @end_transition ? @end_transition.local_end.to_datetime : nil
117:     end

The start time of the period in local time as a DateTime. May be nil if unbounded.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 109
109:     def local_start
110:       @start_transition ? @start_transition.local_start.to_datetime : nil
111:     end

Offset from the local time where daylight savings is in effect (seconds). E.g.: utc_offset could be -5 hours. Normally, std_offset would be 0. During daylight savings, std_offset would typically become +1 hours.

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 72
72:     def std_offset
73:       @offset.std_offset
74:     end

Converts a UTC DateTime to local time based on the offset of this period.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 159
159:     def to_local(utc)
160:       @offset.to_local(utc)
161:     end

Converts a local DateTime to UTC based on the offset of this period.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 164
164:     def to_utc(local)
165:       @offset.to_utc(local)
166:     end

true if the given UTC DateTime is after the start of the period (inclusive); otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 131
131:     def utc_after_start?(utc)
132:       !@start_transition || @start_transition.at <= utc
133:     end

true if the given UTC DateTime is before the end of the period (exclusive); otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 137
137:     def utc_before_end?(utc)
138:       !@end_transition || @end_transition.at > utc
139:     end

The end time of the period in UTC as a DateTime. May be nil if unbounded.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 103
103:     def utc_end
104:       @end_transition ? @end_transition.at.to_datetime : nil
105:     end

Base offset of the timezone from UTC (seconds).

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 65
65:     def utc_offset
66:       @offset.utc_offset
67:     end

The start time of the period in UTC as a DateTime. May be nil if unbounded.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 98
 98:     def utc_start
 99:       @start_transition ? @start_transition.at.to_datetime : nil
100:     end

Total offset from UTC (seconds). Equal to utc_offset + std_offset.

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 85
85:     def utc_total_offset
86:       @offset.utc_total_offset
87:     end

Total offset from UTC (days). Result is a Rational.

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 90
90:     def utc_total_offset_rational
91:       unless @utc_total_offset_rational
92:         @utc_total_offset_rational = OffsetRationals.rational_for_offset(utc_total_offset) 
93:       end
94:       @utc_total_offset_rational
95:     end

true if this period is valid for the given local DateTime; otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 142
142:     def valid_for_local?(local)      
143:       local_after_start?(local) && local_before_end?(local) 
144:     end

true if this period is valid for the given UTC DateTime; otherwise false.

[Source]

     # File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.12/tzinfo/timezone_period.rb, line 125
125:     def valid_for_utc?(utc)
126:       utc_after_start?(utc) && utc_before_end?(utc) 
127:     end
zone_identifier()

Alias for abbreviation

[Validate]