Class: TZInfo::DataTimezone
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
InfoTimezone ,
Timezone
|
|
Instance Chain:
self,
InfoTimezone ,
Timezone ,
Comparable
|
|
Inherits: |
TZInfo::InfoTimezone
|
Defined in: | lib/tzinfo/data_timezone.rb |
Overview
Represents time zones that are defined by rules that set out when transitions occur.
Class Attribute Summary
Timezone
- Inherited
.default_dst | Returns the default value of the optional |
.default_dst= | Sets the default value of the optional |
Class Method Summary
InfoTimezone
- Inherited
.new | Initializes a new |
Timezone
- Inherited
._load | Loads a |
.all | Returns an |
.all_country_zone_identifiers | Returns an |
.all_country_zones | Returns an |
.all_data_zone_identifiers | time zones that are defined by offsets and transitions. |
.all_data_zones | Returns an |
.all_identifiers, | |
.all_linked_zone_identifiers | time zones that are defined as links to / aliases for other time zones. |
.all_linked_zones | Returns an |
.get | Returns a time zone by its IANA Time Zone Database identifier (e.g. |
.get_proxy | Returns a proxy for the time zone with the given identifier. |
.data_source, .get_proxies |
Instance Method Summary
-
#canonical_zone ⇒ Timezone
Returns the canonical
Timezone
instance for thisDataTimezone
. -
#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
TimezonePeriod
s that are valid for the given local time as anArray
. -
#transitions_up_to(to, from = nil) ⇒ Array<TimezoneTransition>
Returns an
Array
ofTimezoneTransition
instances representing the times where the UTC offset of the timezone changes.
InfoTimezone
- Inherited
Timezone
- Inherited
#<=> | Compares this |
#=~ | Matches |
#_dump | Returns a serialized representation of this |
#abbr | Alias for Timezone#abbreviation. |
#abbreviation, | |
#base_utc_offset | Returns the base offset from UTC in seconds at the given time. |
#canonical_identifier | Returns the canonical identifier of this time zone. |
#canonical_zone | |
#current_period, | |
#current_period_and_time | Alias for Timezone#current_time_and_period. |
#current_time_and_period | Returns the current local time and |
#dst?, #eql?, | |
#friendly_identifier | Returns |
#hash, #identifier, #inspect, | |
#local_datetime | Creates a |
#local_time | Creates a |
#local_timestamp | Creates a |
#local_to_utc | Converts a local time for the time zone to UTC. |
#name, #now, | |
#observed_utc_offset | Returns the observed offset from UTC in seconds at the given time. |
#offsets_up_to | Returns the unique offsets used by the time zone up to a given time ( |
#period_for | Returns the |
#period_for_local | Returns the |
#period_for_utc | Returns the |
#periods_for_local | Returns the set of |
#strftime | Converts a time to local time for the time zone and returns a |
#to_local | Converts a time to the local time for the time zone. |
#to_s, | |
#transitions_up_to | Returns an |
#utc_offset | Alias for Timezone#observed_utc_offset. |
#utc_to_local | Converts a time in UTC to the local time for the time zone. |
#raise_unknown_timezone | Raises an |
Constructor Details
This class inherits a constructor from TZInfo::InfoTimezone
Instance Method Details
#canonical_zone ⇒ Timezone
Returns the canonical Timezone
instance for this DataTimezone
.
For a DataTimezone
, this is always self
.
# File '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 period_for_local
and period_for_utc
, the UTC offset of the
time
parameter is taken into consideration.
#periods_for_local(local_time) ⇒ Array
<TimezonePeriod>
Returns the set of TimezonePeriod
s 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
period_for_local
instead and specify how ambiguities should be resolved.
#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.
# File '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