Class | TZInfo::TimezonePeriod |
In: |
vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
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). |
Initializes a new TimezonePeriod.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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
Returns true if this TimezonePeriod is equal to p. This compares the start_transition, end_transition and offset using ==.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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?
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_period.rb, line 154 154: def local_before_end?(local) 155: !@end_transition || @end_transition.local_end > local 156: end
The start time of the period in local time as a DateTime. May be nil if unbounded.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_period.rb, line 72 72: def std_offset 73: @offset.std_offset 74: end
true if the given UTC DateTime is after the start of the period (inclusive); otherwise false.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_period.rb, line 131 131: def utc_after_start?(utc) 132: !@start_transition || @start_transition.at <= utc 133: end
Base offset of the timezone from UTC (seconds).
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/tzinfo/timezone_period.rb, line 65 65: def utc_offset 66: @offset.utc_offset 67: end
Total offset from UTC (seconds). Equal to utc_offset + std_offset.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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.
# File vendor/rails/activesupport/lib/active_support/vendor/tzinfo-0.3.8/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