Class: TZInfo::DataTimezone
- Inherits:
-
InfoTimezone
- Object
- Timezone
- InfoTimezone
- TZInfo::DataTimezone
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_timezone.rb
Overview
Represents time zones that are defined by rules that set out when transitions occur.
Instance Method Summary collapse
-
#canonical_zone ⇒ Timezone
Returns the canonical Timezone instance for this DataTimezone.
-
#period_for(time) ⇒ TimezonePeriod
Returns the TimezonePeriod that is valid at a given time.
-
#periods_for_local(local_time) ⇒ Array<TimezonePeriod>
Returns the set of TimezonePeriods that are valid for the given local time as an ‘Array`.
-
#transitions_up_to(to, from = nil) ⇒ Array<TimezoneTransition>
Returns an ‘Array` of TimezoneTransition instances representing the times where the UTC offset of the timezone changes.
Methods inherited from InfoTimezone
Methods inherited from Timezone
#<=>, #=~, #_dump, _load, #abbreviation, all, all_country_zone_identifiers, all_country_zones, all_data_zone_identifiers, all_data_zones, all_identifiers, all_linked_zone_identifiers, all_linked_zones, #base_utc_offset, #canonical_identifier, #current_period, #current_time_and_period, default_dst, default_dst=, #dst?, #eql?, #friendly_identifier, get, get_proxy, #hash, #identifier, #inspect, #local_datetime, #local_time, #local_timestamp, #local_to_utc, #name, #now, #observed_utc_offset, #offsets_up_to, #period_for_local, #period_for_utc, #strftime, #to_local, #to_s, #utc_to_local
Constructor Details
This class inherits a constructor from TZInfo::InfoTimezone
Instance Method Details
#canonical_zone ⇒ Timezone
Returns the canonical Timezone instance for this TZInfo::DataTimezone.
For a TZInfo::DataTimezone, this is always ‘self`.
40 41 42 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_timezone.rb', line 40 def canonical_zone self end |
#period_for(time) ⇒ TimezonePeriod
Returns the TimezonePeriod that is valid at a given time.
Unlike Timezone#period_for_local and Timezone#period_for_utc, the UTC offset of the ‘time` parameter is taken into consideration.
9 10 11 12 13 14 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_timezone.rb', line 9 def period_for(time) raise ArgumentError, 'time must be specified' unless time = Timestamp.for(time) raise ArgumentError, 'time must have a specified utc_offset' unless .utc_offset info.period_for() end |
#periods_for_local(local_time) ⇒ Array<TimezonePeriod>
Returns the set of TimezonePeriods that are valid for the given local time as an ‘Array`.
The UTC offset of the ‘local_time` parameter is ignored (it is treated as a time in the time zone represented by `self`).
This will typically return an ‘Array` containing a single TimezonePeriod. More than one TimezonePeriod will be returned when the local time is ambiguous (for example, when daylight savings time ends). An empty `Array` will be returned when the local time is not valid (for example, when daylight savings time begins).
To obtain just a single TimezonePeriod in all cases, use Timezone#period_for_local instead and specify how ambiguities should be resolved.
17 18 19 20 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_timezone.rb', line 17 def periods_for_local(local_time) raise ArgumentError, 'local_time must be specified' unless local_time info.periods_for_local(Timestamp.for(local_time, :ignore)) end |
#transitions_up_to(to, from = nil) ⇒ Array<TimezoneTransition>
Returns an ‘Array` of TimezoneTransition instances representing the times where the UTC offset of the timezone changes.
Transitions are returned up to a given time (‘to`).
A from time may also be supplied using the ‘from` parameter. If from is not `nil`, only transitions from that time onwards will be returned.
Comparisons with ‘to` are exclusive. Comparisons with `from` are inclusive. If a transition falls precisely on `to`, it will be excluded. If a transition falls on `from`, it will be included.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_timezone.rb', line 23 def transitions_up_to(to, from = nil) raise ArgumentError, 'to must be specified' unless to = Timestamp.for(to) = from && Timestamp.for(from) begin info.transitions_up_to(, ) rescue ArgumentError => e raise ArgumentError, e..gsub('_timestamp', '') end end |