tzinfo-1.2.2/0000755000004100000410000000000012400401360013043 5ustar www-datawww-datatzinfo-1.2.2/Rakefile0000644000004100000410000000475212400401360014520 0ustar www-datawww-datarequire 'rubygems' require 'rubygems/package_task' require 'fileutils' require 'rake/testtask' # Ignore errors loading rdoc/task (the rdoc tasks will be excluded if # rdoc is unavailable). begin require 'rdoc/task' rescue LoadError, RuntimeError end BASE_DIR = File.expand_path(File.dirname(__FILE__)) task :default => [:test] spec = eval(File.read('tzinfo.gemspec')) class TZInfoPackageTask < Gem::PackageTask alias_method :orig_sh, :sh private :orig_sh def sh(*cmd, &block) if cmd.first =~ /\A__tar_with_owner__ -?([zjcvf]+)(.*)\z/ opts = $1 args = $2 cmd[0] = "tar c --owner 0 --group 0 -#{opts.gsub('c', '')}#{args}" end orig_sh(*cmd, &block) end end def add_signing_key(spec) # Attempt to find the private key and add options to sign the gem if found. private_key_path = File.expand_path(File.join(BASE_DIR, '..', 'key', 'gem-private_key.pem')) if File.exist?(private_key_path) spec = spec.clone spec.signing_key = private_key_path spec.cert_chain = [File.join(BASE_DIR, 'gem-public_cert.pem')] else puts 'WARNING: Private key not found. Not signing gem file.' end spec end package_task = TZInfoPackageTask.new(add_signing_key(spec)) do |pkg| pkg.need_zip = true pkg.need_tar_gz = true pkg.tar_command = '__tar_with_owner__' end # Skip the rdoc task if RDoc::Task is unavailable if defined?(RDoc) && defined?(RDoc::Task) RDoc::Task.new do |rdoc| rdoc.rdoc_dir = 'doc' rdoc.options.concat spec.rdoc_options rdoc.rdoc_files.include(spec.extra_rdoc_files) rdoc.rdoc_files.include('lib') end end Rake::Task[package_task.package_dir_path].enhance do recurse_chmod(package_task.package_dir_path) end Rake::Task[:package].enhance do FileUtils.rm_rf(package_task.package_dir_path) end def recurse_chmod(dir) File.chmod(0755, dir) Dir.entries(dir).each do |entry| if entry != '.' && entry != '..' path = File.join(dir, entry) if File.directory?(path) recurse_chmod(path) else File.chmod(0644, path) end end end end desc 'Run tests using RubyDataSource, then ZoneinfoDataSource' task :test => [:test_ruby, :test_zoneinfo] do end def setup_tests(test_task, type) test_task.libs = [File.join(BASE_DIR, 'lib')] test_task.pattern = File.join(BASE_DIR, 'test', "ts_all_#{type}.rb") test_task.warning = true end Rake::TestTask.new(:test_ruby) do |t| setup_tests(t, :ruby) end Rake::TestTask.new(:test_zoneinfo) do |t| setup_tests(t, :zoneinfo) end tzinfo-1.2.2/data.tar.gz.sig0000444000004100000410000000040012400401360015654 0ustar www-datawww-data[Jp7\Uu i6+Z4-^2I!^eh}\Pջ oQCM钯iK=~/k1HC?_j:^zPxxkylk&Whq74{xhCWxST_7%|!Xs0v+ fW 5sQT@Ч Nm?tc33__>q&l݊u  UİǬbio^髂mcXGʽtzinfo-1.2.2/lib/0000755000004100000410000000000012400401360013611 5ustar www-datawww-datatzinfo-1.2.2/lib/tzinfo.rb0000644000004100000410000000202312400401360015444 0ustar www-datawww-data# Top level module for TZInfo. module TZInfo end require 'tzinfo/ruby_core_support' require 'tzinfo/offset_rationals' require 'tzinfo/time_or_datetime' require 'tzinfo/timezone_definition' require 'tzinfo/timezone_offset' require 'tzinfo/timezone_transition' require 'tzinfo/timezone_transition_definition' require 'tzinfo/timezone_index_definition' require 'tzinfo/timezone_info' require 'tzinfo/data_timezone_info' require 'tzinfo/linked_timezone_info' require 'tzinfo/transition_data_timezone_info' require 'tzinfo/zoneinfo_timezone_info' require 'tzinfo/data_source' require 'tzinfo/ruby_data_source' require 'tzinfo/zoneinfo_data_source' require 'tzinfo/timezone_period' require 'tzinfo/timezone' require 'tzinfo/info_timezone' require 'tzinfo/data_timezone' require 'tzinfo/linked_timezone' require 'tzinfo/timezone_proxy' require 'tzinfo/country_index_definition' require 'tzinfo/country_info' require 'tzinfo/ruby_country_info' require 'tzinfo/zoneinfo_country_info' require 'tzinfo/country' require 'tzinfo/country_timezone' tzinfo-1.2.2/lib/tzinfo/0000755000004100000410000000000012400401360015122 5ustar www-datawww-datatzinfo-1.2.2/lib/tzinfo/data_timezone_info.rb0000644000004100000410000000400612400401360021305 0ustar www-datawww-datamodule TZInfo # Represents a defined timezone containing transition data. class DataTimezoneInfo < TimezoneInfo # Returns the TimezonePeriod for the given UTC time. def period_for_utc(utc) raise_not_implemented('period_for_utc') end # Returns the set of TimezonePeriods for the given local time as an array. # Results returned are ordered by increasing UTC start date. # Returns an empty array if no periods are found for the given time. def periods_for_local(local) raise_not_implemented('periods_for_local') end # Returns an Array of TimezoneTransition instances representing the times # where the UTC offset of the timezone changes. # # Transitions are returned up to a given date and time up to a given date # and time, specified in UTC (utc_to). # # A from date and time may also be supplied using the utc_from parameter # (also specified in UTC). If utc_from is not nil, only transitions from # that date and time onwards will be returned. # # Comparisons with utc_to are exclusive. Comparisons with utc_from are # inclusive. If a transition falls precisely on utc_to, it will be excluded. # If a transition falls on utc_from, it will be included. # # Transitions returned are ordered by when they occur, from earliest to # latest. # # utc_to and utc_from can be specified using either DateTime, Time or # integer timestamps (Time.to_i). # # If utc_from is specified and utc_to is not greater than utc_from, then # transitions_up_to raises an ArgumentError exception. def transitions_up_to(utc_to, utc_from = nil) raise_not_implemented('transitions_up_to') end # Constructs a Timezone instance for the timezone represented by this # DataTimezoneInfo. def create_timezone DataTimezone.new(self) end private def raise_not_implemented(method_name) raise NotImplementedError, "Subclasses must override #{method_name}" end end end tzinfo-1.2.2/lib/tzinfo/country.rb0000644000004100000410000001414712400401360017161 0ustar www-datawww-datarequire 'thread_safe' module TZInfo # Raised by Country#get if the code given is not valid. class InvalidCountryCode < StandardError end # The Country class represents an ISO 3166-1 country. It can be used to # obtain a list of Timezones for a country. For example: # # us = Country.get('US') # us.zone_identifiers # us.zones # us.zone_info # # The Country class is thread-safe. It is safe to use class and instance # methods of Country in concurrently executing threads. Instances of Country # can be shared across thread boundaries. # # Country information available through TZInfo is intended as an aid for # users, to help them select time zone data appropriate for their practical # needs. It is not intended to take or endorse any position on legal or # territorial claims. class Country include Comparable # Defined countries. # # @!visibility private @@countries = nil # Whether the countries index has been loaded yet. # # @!visibility private @@index_loaded = false # Gets a Country by its ISO 3166-1 alpha-2 code. Raises an # InvalidCountryCode exception if it couldn't be found. def self.get(identifier) instance = @@countries[identifier] unless instance # Thread-safety: It is possible that multiple equivalent Country # instances could be created here in concurrently executing threads. # The consequences of this are that the data may be loaded more than # once (depending on the data source) and memoized calculations could # be discarded. The performance benefit of ensuring that only a single # instance is created is unlikely to be worth the overhead of only # allowing one Country to be loaded at a time. info = data_source.load_country_info(identifier) instance = Country.new(info) @@countries[identifier] = instance end instance end # If identifier is a CountryInfo object, initializes the Country instance, # otherwise calls get(identifier). def self.new(identifier) if identifier.kind_of?(CountryInfo) instance = super() instance.send :setup, identifier instance else get(identifier) end end # Returns an Array of all the valid country codes. def self.all_codes data_source.country_codes end # Returns an Array of all the defined Countries. def self.all data_source.country_codes.collect {|code| get(code)} end # The ISO 3166-1 alpha-2 country code. def code @info.code end # The name of the country. def name @info.name end # Alias for name. def to_s name end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #{@info.code}>" end # Returns a frozen array of all the zone identifiers for the country. These # are in an order that # # 1. makes some geographical sense, and # 2. puts the most populous zones first, where that does not contradict 1. # # Returned zone identifiers may refer to cities and regions outside of the # country. This will occur if the zone covers multiple countries. Any zones # referring to a city or region in a different country will be listed after # those relating to this country. def zone_identifiers @info.zone_identifiers end alias zone_names zone_identifiers # An array of all the Timezones for this country. Returns TimezoneProxy # objects to avoid the overhead of loading Timezone definitions until # a conversion is actually required. The Timezones are returned in an order # that # # 1. makes some geographical sense, and # 2. puts the most populous zones first, where that does not contradict 1. # # Identifiers of the zones returned may refer to cities and regions outside # of the country. This will occur if the zone covers multiple countries. Any # zones referring to a city or region in a different country will be listed # after those relating to this country. def zones zone_identifiers.collect {|id| Timezone.get_proxy(id) } end # Returns a frozen array of all the timezones for the for the country as # CountryTimezone instances (containing extra information about each zone). # These are in an order that # # 1. makes some geographical sense, and # 2. puts the most populous zones first, where that does not contradict 1. # # Identifiers and descriptions of the zones returned may refer to cities and # regions outside of the country. This will occur if the zone covers # multiple countries. Any zones referring to a city or region in a different # country will be listed after those relating to this country. def zone_info @info.zones end # Compare two Countries based on their code. Returns -1 if c is less # than self, 0 if c is equal to self and +1 if c is greater than self. # # Returns nil if c is not comparable with Country instances. def <=>(c) return nil unless c.is_a?(Country) code <=> c.code end # Returns true if and only if the code of c is equal to the code of this # Country. def eql?(c) self == c end # Returns a hash value for this Country. def hash code.hash end # Dumps this Country for marshalling. def _dump(limit) code end # Loads a marshalled Country. def self._load(data) Country.get(data) end private # Called by Country.new to initialize a new Country instance. The info # parameter is a CountryInfo that defines the country. def setup(info) @info = info end # Initializes @@countries. def self.init_countries @@countries = ThreadSafe::Cache.new end init_countries # Returns the current DataSource def self.data_source DataSource.get end end end tzinfo-1.2.2/lib/tzinfo/timezone_info.rb0000644000004100000410000000135312400401360020316 0ustar www-datawww-datamodule TZInfo # Represents a timezone defined by a data source. class TimezoneInfo # The timezone identifier. attr_reader :identifier # Constructs a new TimezoneInfo with an identifier. def initialize(identifier) @identifier = identifier end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #@identifier>" end # Constructs a Timezone instance for the timezone represented by this # TimezoneInfo. def create_timezone raise_not_implemented('create_timezone') end private def raise_not_implemented(method_name) raise NotImplementedError, "Subclasses must override #{method_name}" end end end tzinfo-1.2.2/lib/tzinfo/data_source.rb0000644000004100000410000001570412400401360017747 0ustar www-datawww-datarequire 'thread' module TZInfo # InvalidDataSource is raised if the DataSource is used doesn't implement one # of the required methods. class InvalidDataSource < StandardError end # DataSourceNotFound is raised if no data source could be found (i.e. # if 'tzinfo/data' cannot be found on the load path and no valid zoneinfo # directory can be found on the system). class DataSourceNotFound < StandardError end # The base class for data sources of timezone and country data. # # Use DataSource.set to change the data source being used. class DataSource # The currently selected data source. @@instance = nil # Mutex used to ensure the default data source is only created once. @@default_mutex = Mutex.new # Returns the currently selected DataSource instance. def self.get # If a DataSource hasn't been manually set when the first request is # made to obtain a DataSource, then a Default data source is created. # This is done at the first request rather than when TZInfo is loaded to # avoid unnecessary (or in some cases potentially harmful) attempts to # find a suitable DataSource. # A Mutex is used to ensure that only a single default instance is # created (having two different DataSources in use simultaneously could # cause unexpected results). unless @@instance @@default_mutex.synchronize do set(create_default_data_source) unless @@instance end end @@instance end # Sets the currently selected data source for Timezone and Country data. # # This should usually be set to one of the two standard data source types: # # * +:ruby+ - read data from the Ruby modules included in the TZInfo::Data # library (tzinfo-data gem). # * +:zoneinfo+ - read data from the zoneinfo files included with most # Unix-like operating sytems (e.g. in /usr/share/zoneinfo). # # To set TZInfo to use one of the standard data source types, call # \TZInfo::DataSource.set in one of the following ways: # # TZInfo::DataSource.set(:ruby) # TZInfo::DataSource.set(:zoneinfo) # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir) # TZInfo::DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file) # # \DataSource.set(:zoneinfo) will automatically search for the zoneinfo # directory by checking the paths specified in # ZoneinfoDataSource.search_paths. ZoneinfoDirectoryNotFound will be raised # if no valid zoneinfo directory could be found. # # \DataSource.set(:zoneinfo, zoneinfo_dir) uses the specified zoneinfo # directory as the data source. If the directory is not a valid zoneinfo # directory, an InvalidZoneinfoDirectory exception will be raised. # # \DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_tab_file) uses the # specified zoneinfo directory as the data source, but loads the iso3166.tab # file from an alternate path. If the directory is not a valid zoneinfo # directory, an InvalidZoneinfoDirectory exception will be raised. # # Custom data sources can be created by subclassing TZInfo::DataSource and # implementing the following methods: # # * \load_timezone_info # * \timezone_identifiers # * \data_timezone_identifiers # * \linked_timezone_identifiers # * \load_country_info # * \country_codes # # To have TZInfo use the custom data source, call \DataSource.set # as follows: # # TZInfo::DataSource.set(CustomDataSource.new) # # To avoid inconsistent data, \DataSource.set should be called before # accessing any Timezone or Country data. # # If \DataSource.set is not called, TZInfo will by default use TZInfo::Data # as the data source. If TZInfo::Data is not available (i.e. if require # 'tzinfo/data' fails), then TZInfo will search for a zoneinfo directory # instead (using the search path specified by # TZInfo::ZoneinfoDataSource::DEFAULT_SEARCH_PATH). def self.set(data_source_or_type, *args) if data_source_or_type.kind_of?(DataSource) @@instance = data_source_or_type elsif data_source_or_type == :ruby @@instance = RubyDataSource.new elsif data_source_or_type == :zoneinfo @@instance = ZoneinfoDataSource.new(*args) else raise ArgumentError, 'data_source_or_type must be a DataSource instance or a data source type (:ruby)' end end # Returns a TimezoneInfo instance for a given identifier. The TimezoneInfo # instance should derive from either DataTimzoneInfo for timezones that # define their own data or LinkedTimezoneInfo for links or aliases to # other timezones. # # Raises InvalidTimezoneIdentifier if the timezone is not found or the # identifier is invalid. def load_timezone_info(identifier) raise_invalid_data_source('load_timezone_info') end # Returns an array of all the available timezone identifiers. def timezone_identifiers raise_invalid_data_source('timezone_identifiers') end # Returns an array of all the available timezone identifiers for # data timezones (i.e. those that actually contain definitions). def data_timezone_identifiers raise_invalid_data_source('data_timezone_identifiers') end # Returns an array of all the available timezone identifiers that # are links to other timezones. def linked_timezone_identifiers raise_invalid_data_source('linked_timezone_identifiers') end # Returns a CountryInfo instance for the given ISO 3166-1 alpha-2 # country code. Raises InvalidCountryCode if the country could not be found # or the code is invalid. def load_country_info(code) raise_invalid_data_source('load_country_info') end # Returns an array of all the available ISO 3166-1 alpha-2 # country codes. def country_codes raise_invalid_data_source('country_codes') end # Returns the name of this DataSource. def to_s "Default DataSource" end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}>" end private # Creates a DataSource instance for use as the default. Used if # no preference has been specified manually. def self.create_default_data_source has_tzinfo_data = false begin require 'tzinfo/data' has_tzinfo_data = true rescue LoadError end return RubyDataSource.new if has_tzinfo_data begin return ZoneinfoDataSource.new rescue ZoneinfoDirectoryNotFound raise DataSourceNotFound, "No source of timezone data could be found.\nPlease refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error." end end def raise_invalid_data_source(method_name) raise InvalidDataSource, "#{method_name} not defined" end end end tzinfo-1.2.2/lib/tzinfo/country_index_definition.rb0000644000004100000410000000170212400401360022551 0ustar www-datawww-datamodule TZInfo # The country index file includes CountryIndexDefinition which provides # a country method used to define each country in the index. # # @private module CountryIndexDefinition #:nodoc: def self.append_features(base) super base.extend(ClassMethods) base.instance_eval { @countries = {} } end # Class methods for inclusion. # # @private module ClassMethods #:nodoc: # Defines a country with an ISO 3166 country code, name and block. The # block will be evaluated to obtain all the timezones for the country. # Calls Country.country_defined with the definition of each country. def country(code, name, &block) @countries[code] = RubyCountryInfo.new(code, name, &block) end # Returns a frozen hash of all the countries that have been defined in # the index. def countries @countries.freeze end end end end tzinfo-1.2.2/lib/tzinfo/transition_data_timezone_info.rb0000644000004100000410000002325112400401360023562 0ustar www-datawww-datamodule TZInfo # Raised if no offsets have been defined when calling period_for_utc or # periods_for_local. Indicates an error in the timezone data. class NoOffsetsDefined < StandardError end # Represents a data timezone defined by a set of offsets and a set # of transitions. # # @private class TransitionDataTimezoneInfo < DataTimezoneInfo #:nodoc: # Constructs a new TransitionDataTimezoneInfo with its identifier. def initialize(identifier) super(identifier) @offsets = {} @transitions = [] @previous_offset = nil @transitions_index = nil end # Defines a offset. The id uniquely identifies this offset within the # timezone. utc_offset and std_offset define the offset in seconds of # standard time from UTC and daylight savings from standard time # respectively. abbreviation describes the timezone offset (e.g. GMT, BST, # EST or EDT). # # The first offset to be defined is treated as the offset that applies # until the first transition. This will usually be in Local Mean Time (LMT). # # ArgumentError will be raised if the id is already defined. def offset(id, utc_offset, std_offset, abbreviation) raise ArgumentError, 'Offset already defined' if @offsets.has_key?(id) offset = TimezoneOffset.new(utc_offset, std_offset, abbreviation) @offsets[id] = offset @previous_offset = offset unless @previous_offset end # Defines a transition. Transitions must be defined in chronological order. # ArgumentError will be raised if a transition is added out of order. # offset_id refers to an id defined with offset. ArgumentError will be # raised if the offset_id cannot be found. numerator_or_time and # denomiator specify the time the transition occurs as. See # TimezoneTransition for more detail about specifying times. def transition(year, month, offset_id, numerator_or_timestamp, denominator_or_numerator = nil, denominator = nil) offset = @offsets[offset_id] raise ArgumentError, 'Offset not found' unless offset if @transitions_index if year < @last_year || (year == @last_year && month < @last_month) raise ArgumentError, 'Transitions must be increasing date order' end # Record the position of the first transition with this index. index = transition_index(year, month) @transitions_index[index] ||= @transitions.length # Fill in any gaps (index - 1).downto(0) do |i| break if @transitions_index[i] @transitions_index[i] = @transitions.length end else @transitions_index = [@transitions.length] @start_year = year @start_month = month end @transitions << TimezoneTransitionDefinition.new(offset, @previous_offset, numerator_or_timestamp, denominator_or_numerator, denominator) @last_year = year @last_month = month @previous_offset = offset end # Returns the TimezonePeriod for the given UTC time. # Raises NoOffsetsDefined if no offsets have been defined. def period_for_utc(utc) unless @transitions.empty? utc = TimeOrDateTime.wrap(utc) index = transition_index(utc.year, utc.mon) start_transition = nil start = transition_before_end(index) if start start.downto(0) do |i| if @transitions[i].at <= utc start_transition = @transitions[i] break end end end end_transition = nil start = transition_after_start(index) if start start.upto(@transitions.length - 1) do |i| if @transitions[i].at > utc end_transition = @transitions[i] break end end end if start_transition || end_transition TimezonePeriod.new(start_transition, end_transition) else # Won't happen since there are transitions. Must always find one # transition that is either >= or < the specified time. raise 'No transitions found in search' end else raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset TimezonePeriod.new(nil, nil, @previous_offset) end end # Returns the set of TimezonePeriods for the given local time as an array. # Results returned are ordered by increasing UTC start date. # Returns an empty array if no periods are found for the given time. # Raises NoOffsetsDefined if no offsets have been defined. def periods_for_local(local) unless @transitions.empty? local = TimeOrDateTime.wrap(local) index = transition_index(local.year, local.mon) result = [] start_index = transition_after_start(index - 1) if start_index && @transitions[start_index].local_end_at > local if start_index > 0 if @transitions[start_index - 1].local_start_at <= local result << TimezonePeriod.new(@transitions[start_index - 1], @transitions[start_index]) end else result << TimezonePeriod.new(nil, @transitions[start_index]) end end end_index = transition_before_end(index + 1) if end_index start_index = end_index unless start_index start_index.upto(transition_before_end(index + 1)) do |i| if @transitions[i].local_start_at <= local if i + 1 < @transitions.length if @transitions[i + 1].local_end_at > local result << TimezonePeriod.new(@transitions[i], @transitions[i + 1]) end else result << TimezonePeriod.new(@transitions[i], nil) end end end end result else raise NoOffsetsDefined, 'No offsets have been defined' unless @previous_offset [TimezonePeriod.new(nil, nil, @previous_offset)] end end # Returns an Array of TimezoneTransition instances representing the times # where the UTC offset of the timezone changes. # # Transitions are returned up to a given date and time up to a given date # and time, specified in UTC (utc_to). # # A from date and time may also be supplied using the utc_from parameter # (also specified in UTC). If utc_from is not nil, only transitions from # that date and time onwards will be returned. # # Comparisons with utc_to are exclusive. Comparisons with utc_from are # inclusive. If a transition falls precisely on utc_to, it will be excluded. # If a transition falls on utc_from, it will be included. # # Transitions returned are ordered by when they occur, from earliest to # latest. # # utc_to and utc_from can be specified using either DateTime, Time or # integer timestamps (Time.to_i). # # If utc_from is specified and utc_to is not greater than utc_from, then # transitions_up_to raises an ArgumentError exception. def transitions_up_to(utc_to, utc_from = nil) utc_to = TimeOrDateTime.wrap(utc_to) utc_from = utc_from ? TimeOrDateTime.wrap(utc_from) : nil if utc_from && utc_to <= utc_from raise ArgumentError, 'utc_to must be greater than utc_from' end unless @transitions.empty? if utc_from from = transition_after_start(transition_index(utc_from.year, utc_from.mon)) if from while from < @transitions.length && @transitions[from].at < utc_from from += 1 end if from >= @transitions.length return [] end else # utc_from is later than last transition. return [] end else from = 0 end to = transition_before_end(transition_index(utc_to.year, utc_to.mon)) if to while to >= 0 && @transitions[to].at >= utc_to to -= 1 end if to < 0 return [] end else # utc_to is earlier than first transition. return [] end @transitions[from..to] else [] end end private # Returns the index into the @transitions_index array for a given year # and month. def transition_index(year, month) index = (year - @start_year) * 2 index += 1 if month > 6 index -= 1 if @start_month > 6 index end # Returns the index into @transitions of the first transition that occurs # on or after the start of the given index into @transitions_index. # Returns nil if there are no such transitions. def transition_after_start(index) if index >= @transitions_index.length nil else index = 0 if index < 0 @transitions_index[index] end end # Returns the index into @transitions of the first transition that occurs # before the end of the given index into @transitions_index. # Returns nil if there are no such transitions. def transition_before_end(index) index = index + 1 if index <= 0 nil elsif index >= @transitions_index.length @transitions.length - 1 else @transitions_index[index] - 1 end end end end tzinfo-1.2.2/lib/tzinfo/ruby_country_info.rb0000644000004100000410000000452312400401360021232 0ustar www-datawww-datamodule TZInfo # Represents information about a country returned by RubyDataSource. # # @private class RubyCountryInfo < CountryInfo #:nodoc: # Constructs a new CountryInfo with an ISO 3166 country code, name and # block. The block will be evaluated to obtain the timezones for the # country when the zones are first needed. def initialize(code, name, &block) super(code, name) @block = block @zones = nil @zone_identifiers = nil end # Returns a frozen array of all the zone identifiers for the country. These # are in the order they were added using the timezone method. def zone_identifiers # Thread-safety: It is possible that the value of @zone_identifiers may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @zone_identifiers is only # calculated once. unless @zone_identifiers @zone_identifiers = zones.collect {|zone| zone.identifier}.freeze end @zone_identifiers end # Returns a frozen array of all the timezones for the for the country as # CountryTimezone instances. These are in the order they were added using # the timezone method. def zones # Thread-safety: It is possible that the value of @zones may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @zones is only # calculated once. unless @zones zones = Zones.new @block.call(zones) if @block @block = nil @zones = zones.list.freeze end @zones end # An instance of the Zones class is passed to the block used to define # timezones. # # @private class Zones #:nodoc: attr_reader :list def initialize @list = [] end # Called by the index data to define a timezone for the country. def timezone(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = nil) @list << CountryTimezone.new!(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description) end end end end tzinfo-1.2.2/lib/tzinfo/data_timezone.rb0000644000004100000410000000422112400401360020271 0ustar www-datawww-datamodule TZInfo # A Timezone based on a DataTimezoneInfo. # # @private class DataTimezone < InfoTimezone #:nodoc: # Returns the TimezonePeriod for the given UTC time. utc can either be # a DateTime, Time or integer timestamp (Time.to_i). Any timezone # information in utc is ignored (it is treated as a UTC time). # # If no TimezonePeriod could be found, PeriodNotFound is raised. def period_for_utc(utc) info.period_for_utc(utc) end # Returns the set of TimezonePeriod instances that are valid for the given # local time as an array. If you just want a single period, use # period_for_local instead and specify how abiguities should be resolved. # Raises PeriodNotFound if no periods are found for the given time. def periods_for_local(local) info.periods_for_local(local) end # Returns an Array of TimezoneTransition instances representing the times # where the UTC offset of the timezone changes. # # Transitions are returned up to a given date and time up to a given date # and time, specified in UTC (utc_to). # # A from date and time may also be supplied using the utc_from parameter # (also specified in UTC). If utc_from is not nil, only transitions from # that date and time onwards will be returned. # # Comparisons with utc_to are exclusive. Comparisons with utc_from are # inclusive. If a transition falls precisely on utc_to, it will be excluded. # If a transition falls on utc_from, it will be included. # # Transitions returned are ordered by when they occur, from earliest to # latest. # # utc_to and utc_from can be specified using either DateTime, Time or # integer timestamps (Time.to_i). # # If utc_from is specified and utc_to is not greater than utc_from, then # transitions_up_to raises an ArgumentError exception. def transitions_up_to(utc_to, utc_from = nil) info.transitions_up_to(utc_to, utc_from) end # Returns the canonical zone for this Timezone. # # For a DataTimezone, this is always self. def canonical_zone self end end end tzinfo-1.2.2/lib/tzinfo/zoneinfo_country_info.rb0000644000004100000410000000220712400401360022075 0ustar www-datawww-datamodule TZInfo # Represents information about a country returned by ZoneinfoDataSource. # # @private class ZoneinfoCountryInfo < CountryInfo #:nodoc: # Constructs a new CountryInfo with an ISO 3166 country code, name and # an array of CountryTimezones. def initialize(code, name, zones) super(code, name) @zones = zones.dup.freeze @zone_identifiers = nil end # Returns a frozen array of all the zone identifiers for the country ordered # geographically, most populous first. def zone_identifiers # Thread-safety: It is possible that the value of @zone_identifiers may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @zone_identifiers is only # calculated once. unless @zone_identifiers @zone_identifiers = zones.collect {|zone| zone.identifier}.freeze end @zone_identifiers end # Returns a frozen array of all the timezones for the for the country # ordered geographically, most populous first. def zones @zones end end end tzinfo-1.2.2/lib/tzinfo/country_timezone.rb0000644000004100000410000001144312400401360021067 0ustar www-datawww-datamodule TZInfo # A Timezone within a Country. This contains extra information about the # Timezone that is specific to the Country (a Timezone could be used by # multiple countries). class CountryTimezone # The zone identifier. attr_reader :identifier # A description of this timezone in relation to the country, e.g. # "Eastern Time". This is usually nil for countries having only a single # Timezone. attr_reader :description class << self # Creates a new CountryTimezone with a timezone identifier, latitude, # longitude and description. The latitude and longitude are specified as # rationals - a numerator and denominator. For performance reasons, the # numerators and denominators must be specified in their lowest form. # # For use internally within TZInfo. # # @!visibility private alias :new! :new # Creates a new CountryTimezone with a timezone identifier, latitude, # longitude and description. The latitude and longitude must be specified # as instances of Rational. # # CountryTimezone instances should normally only be constructed when # creating new DataSource implementations. def new(identifier, latitude, longitude, description = nil) super(identifier, latitude, nil, longitude, nil, description) end end # Creates a new CountryTimezone with a timezone identifier, latitude, # longitude and description. The latitude and longitude are specified as # rationals - a numerator and denominator. For performance reasons, the # numerators and denominators must be specified in their lowest form. # # @!visibility private def initialize(identifier, latitude_numerator, latitude_denominator, longitude_numerator, longitude_denominator, description = nil) #:nodoc: @identifier = identifier if latitude_numerator.kind_of?(Rational) @latitude = latitude_numerator else @latitude = nil @latitude_numerator = latitude_numerator @latitude_denominator = latitude_denominator end if longitude_numerator.kind_of?(Rational) @longitude = longitude_numerator else @longitude = nil @longitude_numerator = longitude_numerator @longitude_denominator = longitude_denominator end @description = description end # The Timezone (actually a TimezoneProxy for performance reasons). def timezone Timezone.get_proxy(@identifier) end # if description is not nil, this method returns description; otherwise it # returns timezone.friendly_identifier(true). def description_or_friendly_identifier description || timezone.friendly_identifier(true) end # The latitude of this timezone in degrees as a Rational. def latitude # Thread-safety: It is possible that the value of @latitude may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @latitude is only # calculated once. @latitude ||= RubyCoreSupport.rational_new!(@latitude_numerator, @latitude_denominator) end # The longitude of this timezone in degrees as a Rational. def longitude # Thread-safety: It is possible that the value of @longitude may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @longitude is only # calculated once. @longitude ||= RubyCoreSupport.rational_new!(@longitude_numerator, @longitude_denominator) end # Returns true if and only if the given CountryTimezone is equal to the # current CountryTimezone (has the same identifer, latitude, longitude # and description). def ==(ct) ct.kind_of?(CountryTimezone) && identifier == ct.identifier && latitude == ct.latitude && longitude == ct.longitude && description == ct.description end # Returns true if and only if the given CountryTimezone is equal to the # current CountryTimezone (has the same identifer, latitude, longitude # and description). def eql?(ct) self == ct end # Returns a hash of this CountryTimezone. def hash @identifier.hash ^ (@latitude ? @latitude.numerator.hash ^ @latitude.denominator.hash : @latitude_numerator.hash ^ @latitude_denominator.hash) ^ (@longitude ? @longitude.numerator.hash ^ @longitude.denominator.hash : @longitude_numerator.hash ^ @longitude_denominator.hash) ^ @description.hash end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #@identifier>" end end end tzinfo-1.2.2/lib/tzinfo/linked_timezone.rb0000644000004100000410000000456312400401360020637 0ustar www-datawww-datamodule TZInfo # A Timezone based on a LinkedTimezoneInfo. # # @private class LinkedTimezone < InfoTimezone #:nodoc: # Returns the TimezonePeriod for the given UTC time. utc can either be # a DateTime, Time or integer timestamp (Time.to_i). Any timezone # information in utc is ignored (it is treated as a UTC time). # # If no TimezonePeriod could be found, PeriodNotFound is raised. def period_for_utc(utc) @linked_timezone.period_for_utc(utc) end # Returns the set of TimezonePeriod instances that are valid for the given # local time as an array. If you just want a single period, use # period_for_local instead and specify how abiguities should be resolved. # Raises PeriodNotFound if no periods are found for the given time. def periods_for_local(local) @linked_timezone.periods_for_local(local) end # Returns an Array of TimezoneTransition instances representing the times # where the UTC offset of the timezone changes. # # Transitions are returned up to a given date and time up to a given date # and time, specified in UTC (utc_to). # # A from date and time may also be supplied using the utc_from parameter # (also specified in UTC). If utc_from is not nil, only transitions from # that date and time onwards will be returned. # # Comparisons with utc_to are exclusive. Comparisons with utc_from are # inclusive. If a transition falls precisely on utc_to, it will be excluded. # If a transition falls on utc_from, it will be included. # # Transitions returned are ordered by when they occur, from earliest to # latest. # # utc_to and utc_from can be specified using either DateTime, Time or # integer timestamps (Time.to_i). # # If utc_from is specified and utc_to is not greater than utc_from, then # transitions_up_to raises an ArgumentError exception. def transitions_up_to(utc_to, utc_from = nil) @linked_timezone.transitions_up_to(utc_to, utc_from) end # Returns the canonical zone for this Timezone. # # For a LinkedTimezone, this is the canonical zone of the link target. def canonical_zone @linked_timezone.canonical_zone end protected def setup(info) super(info) @linked_timezone = Timezone.get(info.link_to_identifier) end end end tzinfo-1.2.2/lib/tzinfo/country_info.rb0000644000004100000410000000222012400401360020161 0ustar www-datawww-datamodule TZInfo # Represents a country and references to its timezones as returned by a # DataSource. class CountryInfo # The ISO 3166 country code. attr_reader :code # The name of the country. attr_reader :name # Constructs a new CountryInfo with an ISO 3166 country code and name def initialize(code, name) @code = code @name = name end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #@code>" end # Returns a frozen array of all the zone identifiers for the country. # The identifiers are ordered by importance according to the DataSource. def zone_identifiers raise_not_implemented('zone_identifiers') end # Returns a frozen array of all the timezones for the for the country as # CountryTimezone instances. # # The timezones are ordered by importance according to the DataSource. def zones raise_not_implemented('zones') end private def raise_not_implemented(method_name) raise NotImplementedError, "Subclasses must override #{method_name}" end end end tzinfo-1.2.2/lib/tzinfo/timezone_offset.rb0000644000004100000410000000446112400401360020654 0ustar www-datawww-datamodule TZInfo # Represents an offset defined in a Timezone data file. class TimezoneOffset # The base offset of the timezone from UTC in seconds. attr_reader :utc_offset # The offset from standard time for the zone in seconds (i.e. non-zero if # daylight savings is being observed). attr_reader :std_offset # The total offset of this observance from UTC in seconds # (utc_offset + std_offset). attr_reader :utc_total_offset # The abbreviation that identifies this observance, e.g. "GMT" # (Greenwich Mean Time) or "BST" (British Summer Time) for "Europe/London". The returned identifier is a # symbol. attr_reader :abbreviation # Constructs a new TimezoneOffset. utc_offset and std_offset are specified # in seconds. def initialize(utc_offset, std_offset, abbreviation) @utc_offset = utc_offset @std_offset = std_offset @abbreviation = abbreviation @utc_total_offset = @utc_offset + @std_offset end # True if std_offset is non-zero. def dst? @std_offset != 0 end # Converts a UTC Time, DateTime or integer timestamp to local time, based on # the offset of this period. def to_local(utc) TimeOrDateTime.wrap(utc) {|wrapped| wrapped + @utc_total_offset } end # Converts a local Time, DateTime or integer timestamp to UTC, based on the # offset of this period. def to_utc(local) TimeOrDateTime.wrap(local) {|wrapped| wrapped - @utc_total_offset } end # Returns true if and only if toi has the same utc_offset, std_offset # and abbreviation as this TimezoneOffset. def ==(toi) toi.kind_of?(TimezoneOffset) && utc_offset == toi.utc_offset && std_offset == toi.std_offset && abbreviation == toi.abbreviation end # Returns true if and only if toi has the same utc_offset, std_offset # and abbreviation as this TimezoneOffset. def eql?(toi) self == toi end # Returns a hash of this TimezoneOffset. def hash utc_offset.hash ^ std_offset.hash ^ abbreviation.hash end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #@utc_offset,#@std_offset,#@abbreviation>" end end end tzinfo-1.2.2/lib/tzinfo/timezone_definition.rb0000644000004100000410000000172512400401360021516 0ustar www-datawww-datamodule TZInfo # TimezoneDefinition is included into Timezone definition modules. # TimezoneDefinition provides the methods for defining timezones. # # @private module TimezoneDefinition #:nodoc: # Add class methods to the includee. def self.append_features(base) super base.extend(ClassMethods) end # Class methods for inclusion. # # @private module ClassMethods #:nodoc: # Returns and yields a TransitionDataTimezoneInfo object to define a # timezone. def timezone(identifier) yield @timezone = TransitionDataTimezoneInfo.new(identifier) end # Defines a linked timezone. def linked_timezone(identifier, link_to_identifier) @timezone = LinkedTimezoneInfo.new(identifier, link_to_identifier) end # Returns the last TimezoneInfo to be defined with timezone or # linked_timezone. def get @timezone end end end end tzinfo-1.2.2/lib/tzinfo/timezone_transition.rb0000644000004100000410000001020412400401360021550 0ustar www-datawww-datamodule TZInfo # Represents a transition from one timezone offset to another at a particular # date and time. class TimezoneTransition # The offset this transition changes to (a TimezoneOffset instance). attr_reader :offset # The offset this transition changes from (a TimezoneOffset instance). attr_reader :previous_offset # Initializes a new TimezoneTransition. # # TimezoneTransition instances should not normally be constructed manually. def initialize(offset, previous_offset) @offset = offset @previous_offset = previous_offset @local_end_at = nil @local_start_at = nil end # A TimeOrDateTime instance representing the UTC time when this transition # occurs. def at raise_not_implemented('at') end # The UTC time when this transition occurs, returned as a DateTime instance. def datetime at.to_datetime end # The UTC time when this transition occurs, returned as a Time instance. def time at.to_time end # A TimeOrDateTime instance representing the local time when this transition # causes the previous observance to end (calculated from at using # previous_offset). def local_end_at # Thread-safety: It is possible that the value of @local_end_at may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @local_end_at is only # calculated once. @local_end_at = at.add_with_convert(@previous_offset.utc_total_offset) unless @local_end_at @local_end_at end # The local time when this transition causes the previous observance to end, # returned as a DateTime instance. def local_end local_end_at.to_datetime end # The local time when this transition causes the previous observance to end, # returned as a Time instance. def local_end_time local_end_at.to_time end # A TimeOrDateTime instance representing the local time when this transition # causes the next observance to start (calculated from at using offset). def local_start_at # Thread-safety: It is possible that the value of @local_start_at may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @local_start_at is only # calculated once. @local_start_at = at.add_with_convert(@offset.utc_total_offset) unless @local_start_at @local_start_at end # The local time when this transition causes the next observance to start, # returned as a DateTime instance. def local_start local_start_at.to_datetime end # The local time when this transition causes the next observance to start, # returned as a Time instance. def local_start_time local_start_at.to_time end # Returns true if this TimezoneTransition is equal to the given # TimezoneTransition. Two TimezoneTransition instances are # considered to be equal by == if offset, previous_offset and at are all # equal. def ==(tti) tti.kind_of?(TimezoneTransition) && offset == tti.offset && previous_offset == tti.previous_offset && at == tti.at end # Returns true if this TimezoneTransition is equal to the given # TimezoneTransition. Two TimezoneTransition instances are # considered to be equal by eql? if offset, previous_offset and at are all # equal and the type used to define at in both instances is the same. def eql?(tti) tti.kind_of?(TimezoneTransition) && offset == tti.offset && previous_offset == tti.previous_offset && at.eql?(tti.at) end # Returns a hash of this TimezoneTransition instance. def hash @offset.hash ^ @previous_offset.hash ^ at.hash end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #{at.inspect},#{@offset.inspect}>" end private def raise_not_implemented(method_name) raise NotImplementedError, "Subclasses must override #{method_name}" end end end tzinfo-1.2.2/lib/tzinfo/timezone_period.rb0000644000004100000410000001557612400401360020661 0ustar www-datawww-datamodule TZInfo # A period of time in a timezone where the same offset from UTC applies. # # All the methods that take times accept instances of Time or DateTime as well # as Integer timestamps. class TimezonePeriod # The TimezoneTransition that defines the start of this TimezonePeriod # (may be nil if unbounded). attr_reader :start_transition # The TimezoneTransition that defines the end of this TimezonePeriod # (may be nil if unbounded). attr_reader :end_transition # The TimezoneOffset for this period. attr_reader :offset # Initializes a new TimezonePeriod. # # TimezonePeriod instances should not normally be constructed manually. def initialize(start_transition, end_transition, offset = nil) @start_transition = start_transition @end_transition = end_transition if offset raise ArgumentError, 'Offset specified with transitions' if @start_transition || @end_transition @offset = offset else if @start_transition @offset = @start_transition.offset elsif @end_transition @offset = @end_transition.previous_offset else raise ArgumentError, 'No offset specified and no transitions to determine it from' end end @utc_total_offset_rational = nil end # Base offset of the timezone from UTC (seconds). def utc_offset @offset.utc_offset 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. def std_offset @offset.std_offset 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. def abbreviation @offset.abbreviation end alias :zone_identifier :abbreviation # Total offset from UTC (seconds). Equal to utc_offset + std_offset. def utc_total_offset @offset.utc_total_offset end # Total offset from UTC (days). Result is a Rational. def utc_total_offset_rational # Thread-safety: It is possible that the value of # @utc_total_offset_rational may be calculated multiple times in # concurrently executing threads. It is not worth the overhead of locking # to ensure that @zone_identifiers is only calculated once. unless @utc_total_offset_rational @utc_total_offset_rational = OffsetRationals.rational_for_offset(utc_total_offset) end @utc_total_offset_rational end # The start time of the period in UTC as a DateTime. May be nil if unbounded. def utc_start @start_transition ? @start_transition.at.to_datetime : nil end # The start time of the period in UTC as a Time. May be nil if unbounded. def utc_start_time @start_transition ? @start_transition.at.to_time : nil end # The end time of the period in UTC as a DateTime. May be nil if unbounded. def utc_end @end_transition ? @end_transition.at.to_datetime : nil end # The end time of the period in UTC as a Time. May be nil if unbounded. def utc_end_time @end_transition ? @end_transition.at.to_time : nil end # The start time of the period in local time as a DateTime. May be nil if # unbounded. def local_start @start_transition ? @start_transition.local_start_at.to_datetime : nil end # The start time of the period in local time as a Time. May be nil if # unbounded. def local_start_time @start_transition ? @start_transition.local_start_at.to_time : nil end # The end time of the period in local time as a DateTime. May be nil if # unbounded. def local_end @end_transition ? @end_transition.local_end_at.to_datetime : nil end # The end time of the period in local time as a Time. May be nil if # unbounded. def local_end_time @end_transition ? @end_transition.local_end_at.to_time : nil end # true if daylight savings is in effect for this period; otherwise false. def dst? @offset.dst? end # true if this period is valid for the given UTC DateTime; otherwise false. def valid_for_utc?(utc) utc_after_start?(utc) && utc_before_end?(utc) end # true if the given UTC DateTime is after the start of the period # (inclusive); otherwise false. def utc_after_start?(utc) !@start_transition || @start_transition.at <= utc end # true if the given UTC DateTime is before the end of the period # (exclusive); otherwise false. def utc_before_end?(utc) !@end_transition || @end_transition.at > utc end # true if this period is valid for the given local DateTime; otherwise false. def valid_for_local?(local) local_after_start?(local) && local_before_end?(local) end # true if the given local DateTime is after the start of the period # (inclusive); otherwise false. def local_after_start?(local) !@start_transition || @start_transition.local_start_at <= local end # true if the given local DateTime is before the end of the period # (exclusive); otherwise false. def local_before_end?(local) !@end_transition || @end_transition.local_end_at > local end # Converts a UTC DateTime to local time based on the offset of this period. def to_local(utc) @offset.to_local(utc) end # Converts a local DateTime to UTC based on the offset of this period. def to_utc(local) @offset.to_utc(local) end # Returns true if this TimezonePeriod is equal to p. This compares the # start_transition, end_transition and offset using ==. def ==(p) p.kind_of?(TimezonePeriod) && start_transition == p.start_transition && end_transition == p.end_transition && offset == p.offset end # Returns true if this TimezonePeriods is equal to p. This compares the # start_transition, end_transition and offset using eql? def eql?(p) p.kind_of?(TimezonePeriod) && start_transition.eql?(p.start_transition) && end_transition.eql?(p.end_transition) && offset.eql?(p.offset) end # Returns a hash of this TimezonePeriod. def hash result = @start_transition.hash ^ @end_transition.hash result ^= @offset.hash unless @start_transition || @end_transition result end # Returns internal object state as a programmer-readable string. def inspect result = "#<#{self.class}: #{@start_transition.inspect},#{@end_transition.inspect}" result << ",#{@offset.inspect}>" unless @start_transition || @end_transition result + '>' end end end tzinfo-1.2.2/lib/tzinfo/timezone.rb0000644000004100000410000005671612400401360017320 0ustar www-datawww-datarequire 'date' require 'set' require 'thread_safe' module TZInfo # AmbiguousTime is raised to indicates that a specified time in a local # timezone has more than one possible equivalent UTC time. This happens when # transitioning from daylight savings time to standard time where the clocks # are rolled back. # # AmbiguousTime is raised by period_for_local and local_to_utc when using an # ambiguous time and not specifying any means to resolve the ambiguity. class AmbiguousTime < StandardError end # PeriodNotFound is raised to indicate that no TimezonePeriod matching a given # time could be found. class PeriodNotFound < StandardError end # Raised by Timezone#get if the identifier given is not valid. class InvalidTimezoneIdentifier < StandardError end # Raised if an attempt is made to use a timezone created with # Timezone.new(nil). class UnknownTimezone < StandardError end # Timezone is the base class of all timezones. It provides a factory method, # 'get', to access timezones by identifier. Once a specific Timezone has been # retrieved, DateTimes, Times and timestamps can be converted between the UTC # and the local time for the zone. For example: # # tz = TZInfo::Timezone.get('America/New_York') # puts tz.utc_to_local(DateTime.new(2005,8,29,15,35,0)).to_s # puts tz.local_to_utc(Time.utc(2005,8,29,11,35,0)).to_s # puts tz.utc_to_local(1125315300).to_s # # Each time conversion method returns an object of the same type it was # passed. # # The Timezone class is thread-safe. It is safe to use class and instance # methods of Timezone in concurrently executing threads. Instances of Timezone # can be shared across thread boundaries. class Timezone include Comparable # Cache of loaded zones by identifier to avoid using require if a zone # has already been loaded. # # @!visibility private @@loaded_zones = nil # Default value of the dst parameter of the local_to_utc and # period_for_local methods. # # @!visibility private @@default_dst = nil # Sets the default value of the optional dst parameter of the # local_to_utc and period_for_local methods. Can be set to nil, true or # false. # # The value of default_dst defaults to nil if unset. def self.default_dst=(value) @@default_dst = value.nil? ? nil : !!value end # Gets the default value of the optional dst parameter of the # local_to_utc and period_for_local methods. Can be set to nil, true or # false. def self.default_dst @@default_dst end # Returns a timezone by its identifier (e.g. "Europe/London", # "America/Chicago" or "UTC"). # # Raises InvalidTimezoneIdentifier if the timezone couldn't be found. def self.get(identifier) instance = @@loaded_zones[identifier] unless instance # Thread-safety: It is possible that multiple equivalent Timezone # instances could be created here in concurrently executing threads. # The consequences of this are that the data may be loaded more than # once (depending on the data source) and memoized calculations could # be discarded. The performance benefit of ensuring that only a single # instance is created is unlikely to be worth the overhead of only # allowing one Timezone to be loaded at a time. info = data_source.load_timezone_info(identifier) instance = info.create_timezone @@loaded_zones[instance.identifier] = instance end instance end # Returns a proxy for the Timezone with the given identifier. The proxy # will cause the real timezone to be loaded when an attempt is made to # find a period or convert a time. get_proxy will not validate the # identifier. If an invalid identifier is specified, no exception will be # raised until the proxy is used. def self.get_proxy(identifier) TimezoneProxy.new(identifier) end # If identifier is nil calls super(), otherwise calls get. An identfier # should always be passed in when called externally. def self.new(identifier = nil) if identifier get(identifier) else super() end end # Returns an array containing all the available Timezones. # # Returns TimezoneProxy objects to avoid the overhead of loading Timezone # definitions until a conversion is actually required. def self.all get_proxies(all_identifiers) end # Returns an array containing the identifiers of all the available # Timezones. def self.all_identifiers data_source.timezone_identifiers end # Returns an array containing all the available Timezones that are based # on data (are not links to other Timezones). # # Returns TimezoneProxy objects to avoid the overhead of loading Timezone # definitions until a conversion is actually required. def self.all_data_zones get_proxies(all_data_zone_identifiers) end # Returns an array containing the identifiers of all the available # Timezones that are based on data (are not links to other Timezones).. def self.all_data_zone_identifiers data_source.data_timezone_identifiers end # Returns an array containing all the available Timezones that are links # to other Timezones. # # Returns TimezoneProxy objects to avoid the overhead of loading Timezone # definitions until a conversion is actually required. def self.all_linked_zones get_proxies(all_linked_zone_identifiers) end # Returns an array containing the identifiers of all the available # Timezones that are links to other Timezones. def self.all_linked_zone_identifiers data_source.linked_timezone_identifiers end # Returns all the Timezones defined for all Countries. This is not the # complete set of Timezones as some are not country specific (e.g. # 'Etc/GMT'). # # Returns TimezoneProxy objects to avoid the overhead of loading Timezone # definitions until a conversion is actually required. def self.all_country_zones Country.all_codes.inject([]) do |zones,country| zones += Country.get(country).zones end.uniq end # Returns all the zone identifiers defined for all Countries. This is not the # complete set of zone identifiers as some are not country specific (e.g. # 'Etc/GMT'). You can obtain a Timezone instance for a given identifier # with the get method. def self.all_country_zone_identifiers Country.all_codes.inject([]) do |zones,country| zones += Country.get(country).zone_identifiers end.uniq end # Returns all US Timezone instances. A shortcut for # TZInfo::Country.get('US').zones. # # Returns TimezoneProxy objects to avoid the overhead of loading Timezone # definitions until a conversion is actually required. def self.us_zones Country.get('US').zones end # Returns all US zone identifiers. A shortcut for # TZInfo::Country.get('US').zone_identifiers. def self.us_zone_identifiers Country.get('US').zone_identifiers end # The identifier of the timezone, e.g. "Europe/Paris". def identifier raise_unknown_timezone end # An alias for identifier. def name # Don't use alias, as identifier gets overridden. identifier end # Returns a friendlier version of the identifier. def to_s friendly_identifier end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #{identifier}>" end # Returns a friendlier version of the identifier. Set skip_first_part to # omit the first part of the identifier (typically a region name) where # there is more than one part. # # For example: # # Timezone.get('Europe/Paris').friendly_identifier(false) #=> "Europe - Paris" # Timezone.get('Europe/Paris').friendly_identifier(true) #=> "Paris" # Timezone.get('America/Indiana/Knox').friendly_identifier(false) #=> "America - Knox, Indiana" # Timezone.get('America/Indiana/Knox').friendly_identifier(true) #=> "Knox, Indiana" def friendly_identifier(skip_first_part = false) parts = identifier.split('/') if parts.empty? # shouldn't happen identifier elsif parts.length == 1 parts[0] else if skip_first_part result = '' else result = parts[0] + ' - ' end parts[1, parts.length - 1].reverse_each {|part| part.gsub!(/_/, ' ') if part.index(/[a-z]/) # Missing a space if a lower case followed by an upper case and the # name isn't McXxxx. part.gsub!(/([^M][a-z])([A-Z])/, '\1 \2') part.gsub!(/([M][a-bd-z])([A-Z])/, '\1 \2') # Missing an apostrophe if two consecutive upper case characters. part.gsub!(/([A-Z])([A-Z])/, '\1\'\2') end result << part result << ', ' } result.slice!(result.length - 2, 2) result end end # Returns the TimezonePeriod for the given UTC time. utc can either be # a DateTime, Time or integer timestamp (Time.to_i). Any timezone # information in utc is ignored (it is treated as a UTC time). def period_for_utc(utc) raise_unknown_timezone end # Returns the set of TimezonePeriod instances that are valid for the given # local time as an array. If you just want a single period, use # period_for_local instead and specify how ambiguities should be resolved. # Returns an empty array if no periods are found for the given time. def periods_for_local(local) raise_unknown_timezone end # Returns an Array of TimezoneTransition instances representing the times # where the UTC offset of the timezone changes. # # Transitions are returned up to a given date and time up to a given date # and time, specified in UTC (utc_to). # # A from date and time may also be supplied using the utc_from parameter # (also specified in UTC). If utc_from is not nil, only transitions from # that date and time onwards will be returned. # # Comparisons with utc_to are exclusive. Comparisons with utc_from are # inclusive. If a transition falls precisely on utc_to, it will be excluded. # If a transition falls on utc_from, it will be included. # # Transitions returned are ordered by when they occur, from earliest to # latest. # # utc_to and utc_from can be specified using either DateTime, Time or # integer timestamps (Time.to_i). # # If utc_from is specified and utc_to is not greater than utc_from, then # transitions_up_to raises an ArgumentError exception. def transitions_up_to(utc_to, utc_from = nil) raise_unknown_timezone end # Returns the canonical Timezone instance for this Timezone. # # The IANA Time Zone database contains two types of definition: Zones and # Links. Zones are defined by rules that set out when transitions occur. # Links are just references to fully defined Zone, creating an alias for # that Zone. # # Links are commonly used where a time zone has been renamed in a # release of the Time Zone database. For example, the Zone US/Eastern was # renamed as America/New_York. A US/Eastern Link was added in its place, # linking to (and creating an alias for) for America/New_York. # # Links are also used for time zones that are currently identical to a full # Zone, but that are administered seperately. For example, Europe/Vatican is # a Link to (and alias for) Europe/Rome. # # For a full Zone, canonical_zone returns self. # # For a Link, canonical_zone returns a Timezone instance representing the # full Zone that the link targets. # # TZInfo can be used with different data sources (see the documentation for # TZInfo::DataSource). Please note that some DataSource implementations may # not support distinguishing between full Zones and Links and will treat all # time zones as full Zones. In this case, the canonical_zone will always # return self. # # There are two built-in DataSource implementations. RubyDataSource (which # will be used if the tzinfo-data gem is available) supports Link zones. # ZoneinfoDataSource returns Link zones as if they were full Zones. If the # canonical_zone or canonical_identifier methods are required, the # tzinfo-data gem should be installed. # # The TZInfo::DataSource.get method can be used to check which DataSource # implementation is being used. def canonical_zone raise_unknown_timezone end # Returns the TimezonePeriod for the given local time. local can either be # a DateTime, Time or integer timestamp (Time.to_i). Any timezone # information in local is ignored (it is treated as a time in the current # timezone). # # Warning: There are local times that have no equivalent UTC times (e.g. # in the transition from standard time to daylight savings time). There are # also local times that have more than one UTC equivalent (e.g. in the # transition from daylight savings time to standard time). # # In the first case (no equivalent UTC time), a PeriodNotFound exception # will be raised. # # In the second case (more than one equivalent UTC time), an AmbiguousTime # exception will be raised unless the optional dst parameter or block # handles the ambiguity. # # If the ambiguity is due to a transition from daylight savings time to # standard time, the dst parameter can be used to select whether the # daylight savings time or local time is used. For example, # # Timezone.get('America/New_York').period_for_local(DateTime.new(2004,10,31,1,30,0)) # # would raise an AmbiguousTime exception. # # Specifying dst=true would the daylight savings period from April to # October 2004. Specifying dst=false would return the standard period # from October 2004 to April 2005. # # If the dst parameter does not resolve the ambiguity, and a block is # specified, it is called. The block must take a single parameter - an # array of the periods that need to be resolved. The block can select and # return a single period or return nil or an empty array # to cause an AmbiguousTime exception to be raised. # # The default value of the dst parameter can be specified by setting # Timezone.default_dst. If default_dst is not set, or is set to nil, then # an AmbiguousTime exception will be raised in ambiguous situations unless # a block is given to resolve the ambiguity. def period_for_local(local, dst = Timezone.default_dst) results = periods_for_local(local) if results.empty? raise PeriodNotFound elsif results.size < 2 results.first else # ambiguous result try to resolve if !dst.nil? matches = results.find_all {|period| period.dst? == dst} results = matches if !matches.empty? end if results.size < 2 results.first else # still ambiguous, try the block if block_given? results = yield results end if results.is_a?(TimezonePeriod) results elsif results && results.size == 1 results.first else raise AmbiguousTime, "#{local} is an ambiguous local time." end end end end # Converts a time in UTC to the local timezone. utc can either be # a DateTime, Time or timestamp (Time.to_i). The returned time has the same # type as utc. Any timezone information in utc is ignored (it is treated as # a UTC time). def utc_to_local(utc) TimeOrDateTime.wrap(utc) {|wrapped| period_for_utc(wrapped).to_local(wrapped) } end # Converts a time in the local timezone to UTC. local can either be # a DateTime, Time or timestamp (Time.to_i). The returned time has the same # type as local. Any timezone information in local is ignored (it is treated # as a local time). # # Warning: There are local times that have no equivalent UTC times (e.g. # in the transition from standard time to daylight savings time). There are # also local times that have more than one UTC equivalent (e.g. in the # transition from daylight savings time to standard time). # # In the first case (no equivalent UTC time), a PeriodNotFound exception # will be raised. # # In the second case (more than one equivalent UTC time), an AmbiguousTime # exception will be raised unless the optional dst parameter or block # handles the ambiguity. # # If the ambiguity is due to a transition from daylight savings time to # standard time, the dst parameter can be used to select whether the # daylight savings time or local time is used. For example, # # Timezone.get('America/New_York').local_to_utc(DateTime.new(2004,10,31,1,30,0)) # # would raise an AmbiguousTime exception. # # Specifying dst=true would return 2004-10-31 5:30:00. Specifying dst=false # would return 2004-10-31 6:30:00. # # If the dst parameter does not resolve the ambiguity, and a block is # specified, it is called. The block must take a single parameter - an # array of the periods that need to be resolved. The block can return a # single period to use to convert the time or return nil or an empty array # to cause an AmbiguousTime exception to be raised. # # The default value of the dst parameter can be specified by setting # Timezone.default_dst. If default_dst is not set, or is set to nil, then # an AmbiguousTime exception will be raised in ambiguous situations unless # a block is given to resolve the ambiguity. def local_to_utc(local, dst = Timezone.default_dst) TimeOrDateTime.wrap(local) {|wrapped| if block_given? period = period_for_local(wrapped, dst) {|periods| yield periods } else period = period_for_local(wrapped, dst) end period.to_utc(wrapped) } end # Returns information about offsets used by the Timezone up to a given # date and time, specified using UTC (utc_to). The information is returned # as an Array of TimezoneOffset instances. # # A from date and time may also be supplied using the utc_from parameter # (also specified in UTC). If utc_from is not nil, only offsets used from # that date and time forward will be returned. # # Comparisons with utc_to are exclusive. Comparisons with utc_from are # inclusive. # # Offsets may be returned in any order. # # utc_to and utc_from can be specified using either DateTime, Time or # integer timestamps (Time.to_i). # # If utc_from is specified and utc_to is not greater than utc_from, then # offsets_up_to raises an ArgumentError exception. def offsets_up_to(utc_to, utc_from = nil) utc_to = TimeOrDateTime.wrap(utc_to) transitions = transitions_up_to(utc_to, utc_from) if transitions.empty? # No transitions in the range, find the period that covers it. if utc_from # Use the from date as it is inclusive. period = period_for_utc(utc_from) else # utc_to is exclusive, so this can't be used with period_for_utc. # However, any time earlier than utc_to can be used. # Subtract 1 hour (since this is one of the cached OffsetRationals). # Use add_with_convert so that conversion to DateTime is performed if # required. period = period_for_utc(utc_to.add_with_convert(-3600)) end [period.offset] else result = Set.new first = transitions.first result << first.previous_offset unless utc_from && first.at == utc_from transitions.each do |t| result << t.offset end result.to_a end end # Returns the canonical identifier for this Timezone. # # This is a shortcut for calling canonical_zone.identifier. Please refer # to the canonical_zone documentation for further information. def canonical_identifier canonical_zone.identifier end # Returns the current time in the timezone as a Time. def now utc_to_local(Time.now.utc) end # Returns the TimezonePeriod for the current time. def current_period period_for_utc(Time.now.utc) end # Returns the current Time and TimezonePeriod as an array. The first element # is the time, the second element is the period. def current_period_and_time utc = Time.now.utc period = period_for_utc(utc) [period.to_local(utc), period] end alias :current_time_and_period :current_period_and_time # Converts a time in UTC to local time and returns it as a string # according to the given format. The formatting is identical to # Time.strftime and DateTime.strftime, except %Z is replaced with the # timezone abbreviation for the specified time (for example, EST or EDT). def strftime(format, utc = Time.now.utc) period = period_for_utc(utc) local = period.to_local(utc) local = Time.at(local).utc unless local.kind_of?(Time) || local.kind_of?(DateTime) abbreviation = period.abbreviation.to_s.gsub(/%/, '%%') format = format.gsub(/(.?)%Z/) do if $1 == '%' # return %%Z so the real strftime treats it as a literal %Z too '%%Z' else "#$1#{abbreviation}" end end local.strftime(format) end # Compares two Timezones based on their identifier. Returns -1 if tz is less # than self, 0 if tz is equal to self and +1 if tz is greater than self. # # Returns nil if tz is not comparable with Timezone instances. def <=>(tz) return nil unless tz.is_a?(Timezone) identifier <=> tz.identifier end # Returns true if and only if the identifier of tz is equal to the # identifier of this Timezone. def eql?(tz) self == tz end # Returns a hash of this Timezone. def hash identifier.hash end # Dumps this Timezone for marshalling. def _dump(limit) identifier end # Loads a marshalled Timezone. def self._load(data) Timezone.get(data) end private # Initializes @@loaded_zones. def self.init_loaded_zones @@loaded_zones = ThreadSafe::Cache.new end init_loaded_zones # Returns an array of proxies corresponding to the given array of # identifiers. def self.get_proxies(identifiers) identifiers.collect {|identifier| get_proxy(identifier)} end # Returns the current DataSource. def self.data_source DataSource.get end # Raises an UnknownTimezone exception. def raise_unknown_timezone raise UnknownTimezone, 'TZInfo::Timezone constructed directly' end end end tzinfo-1.2.2/lib/tzinfo/zoneinfo_timezone_info.rb0000644000004100000410000002134512400401360022230 0ustar www-datawww-datamodule TZInfo # An InvalidZoneinfoFile exception is raised if an attempt is made to load an # invalid zoneinfo file. class InvalidZoneinfoFile < StandardError end # Represents a timezone defined by a compiled zoneinfo TZif (\0, 2 or 3) file. # # @private class ZoneinfoTimezoneInfo < TransitionDataTimezoneInfo #:nodoc: # Minimum supported timestamp (inclusive). # # Time.utc(1700, 1, 1).to_i MIN_TIMESTAMP = -8520336000 # Maximum supported timestamp (exclusive). # # Time.utc(2500, 1, 1).to_i MAX_TIMESTAMP = 16725225600 # Constructs the new ZoneinfoTimezoneInfo with an identifier and path # to the file. def initialize(identifier, file_path) super(identifier) File.open(file_path, 'rb') do |file| parse(file) end end private # Unpack will return unsigned 32-bit integers. Translate to # signed 32-bit. def make_signed_int32(long) long >= 0x80000000 ? long - 0x100000000 : long end # Unpack will return a 64-bit integer as two unsigned 32-bit integers # (most significant first). Translate to signed 64-bit def make_signed_int64(high, low) unsigned = (high << 32) | low unsigned >= 0x8000000000000000 ? unsigned - 0x10000000000000000 : unsigned end # Read bytes from file and check that the correct number of bytes could # be read. Raises InvalidZoneinfoFile if the number of bytes didn't match # the number requested. def check_read(file, bytes) result = file.read(bytes) unless result && result.length == bytes raise InvalidZoneinfoFile, "Expected #{bytes} bytes reading '#{file.path}', but got #{result ? result.length : 0} bytes" end result end # Zoneinfo doesn't include the offset from standard time (std_offset). # Derive the missing offsets by looking at changes in the total UTC # offset. # # This will be run through forwards and then backwards by the parse # method. def derive_offsets(transitions, offsets) previous_offset = nil transitions.each do |t| offset = offsets[t[:offset]] if !offset[:std_offset] && offset[:is_dst] && previous_offset difference = offset[:utc_total_offset] - previous_offset[:utc_total_offset] if previous_offset[:is_dst] if previous_offset[:std_offset] std_offset = previous_offset[:std_offset] + difference else std_offset = nil end else std_offset = difference end if std_offset && std_offset > 0 offset[:std_offset] = std_offset offset[:utc_offset] = offset[:utc_total_offset] - std_offset end end previous_offset = offset end end # Parses a zoneinfo file and intializes the DataTimezoneInfo structures. def parse(file) magic, version, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt, typecnt, charcnt = check_read(file, 44).unpack('a4 a x15 NNNNNN') if magic != 'TZif' raise InvalidZoneinfoFile, "The file '#{file.path}' does not start with the expected header." end if (version == '2' || version == '3') && RubyCoreSupport.time_supports_64bit # Skip the first 32-bit section and read the header of the second 64-bit section file.seek(timecnt * 5 + typecnt * 6 + charcnt + leapcnt * 8 + ttisgmtcnt + ttisstdcnt, IO::SEEK_CUR) prev_version = version magic, version, ttisgmtcnt, ttisstdcnt, leapcnt, timecnt, typecnt, charcnt = check_read(file, 44).unpack('a4 a x15 NNNNNN') unless magic == 'TZif' && (version == prev_version) raise InvalidZoneinfoFile, "The file '#{file.path}' contains an invalid 64-bit section header." end using_64bit = true elsif version != '3' && version != '2' && version != "\0" raise InvalidZoneinfoFile, "The file '#{file.path}' contains a version of the zoneinfo format that is not currently supported." else using_64bit = false end unless leapcnt == 0 raise InvalidZoneinfoFile, "The zoneinfo file '#{file.path}' contains leap second data. TZInfo requires zoneinfo files that omit leap seconds." end transitions = [] if using_64bit (0...timecnt).each do |i| high, low = check_read(file, 8).unpack('NN') transition_time = make_signed_int64(high, low) transitions << {:at => transition_time} end else (0...timecnt).each do |i| transition_time = make_signed_int32(check_read(file, 4).unpack('N')[0]) transitions << {:at => transition_time} end end (0...timecnt).each do |i| localtime_type = check_read(file, 1).unpack('C')[0] transitions[i][:offset] = localtime_type end offsets = [] (0...typecnt).each do |i| gmtoff, isdst, abbrind = check_read(file, 6).unpack('NCC') gmtoff = make_signed_int32(gmtoff) isdst = isdst == 1 offset = {:utc_total_offset => gmtoff, :is_dst => isdst, :abbr_index => abbrind} unless isdst offset[:utc_offset] = gmtoff offset[:std_offset] = 0 end offsets << offset end abbrev = check_read(file, charcnt) offsets.each do |o| abbrev_start = o[:abbr_index] raise InvalidZoneinfoFile, "Abbreviation index is out of range in file '#{file.path}'" unless abbrev_start < abbrev.length abbrev_end = abbrev.index("\0", abbrev_start) raise InvalidZoneinfoFile, "Missing abbreviation null terminator in file '#{file.path}'" unless abbrev_end o[:abbr] = RubyCoreSupport.force_encoding(abbrev[abbrev_start...abbrev_end], 'UTF-8') end transitions.each do |t| if t[:offset] < 0 || t[:offset] >= offsets.length raise InvalidZoneinfoFile, "Invalid offset referenced by transition in file '#{file.path}'." end end # Derive the offsets from standard time (std_offset). derive_offsets(transitions, offsets) derive_offsets(transitions.reverse, offsets) # Assign anything left a standard offset of one hour offsets.each do |o| if !o[:std_offset] && o[:is_dst] o[:std_offset] = 3600 o[:utc_offset] = o[:utc_total_offset] - 3600 end end # Find the first non-dst offset. This is used as the offset for the time # before the first transition. first = nil offsets.each_with_index do |o, i| if !o[:is_dst] first = i break end end if first offset first, offsets[first][:utc_offset], offsets[first][:std_offset], offsets[first][:abbr].untaint.to_sym end offsets.each_with_index do |o, i| offset i, o[:utc_offset], o[:std_offset], o[:abbr].untaint.to_sym unless i == first end if !using_64bit && !RubyCoreSupport.time_supports_negative # Filter out transitions that are not supported by Time on this # platform. # Move the last transition before the epoch up to the epoch. This # allows for accurate conversions for all supported timestamps on the # platform. before_epoch, after_epoch = transitions.partition {|t| t[:at] < 0} if before_epoch.length > 0 && after_epoch.length > 0 && after_epoch.first[:at] != 0 last_before = before_epoch.last last_before[:at] = 0 transitions = [last_before] + after_epoch else transitions = after_epoch end end # Ignore transitions that occur outside of a defined window. The # transition index cannot handle a large range of transition times. # # This is primarily intended to ignore the far in the past transition # added in zic 2014c (at timestamp -2**63 in zic 2014c and at the # approximate time of the big bang from zic 2014d). transitions.each do |t| at = t[:at] if at >= MIN_TIMESTAMP && at < MAX_TIMESTAMP time = Time.at(at).utc transition time.year, time.mon, t[:offset], at end end end end end tzinfo-1.2.2/lib/tzinfo/timezone_transition_definition.rb0000644000004100000410000000733012400401360023766 0ustar www-datawww-datamodule TZInfo # A TimezoneTransition defined by as integer timestamp, as a rational to # create a DateTime or as both. # # @private class TimezoneTransitionDefinition < TimezoneTransition #:nodoc: # The numerator of the DateTime if the transition time is defined as a # DateTime, otherwise the transition time as a timestamp. attr_reader :numerator_or_time protected :numerator_or_time # Either the denominator of the DateTime if the transition time is defined # as a DateTime, otherwise nil. attr_reader :denominator protected :denominator # Creates a new TimezoneTransitionDefinition with the given offset, # previous_offset (both TimezoneOffset instances) and UTC time. # # The time can be specified as a timestamp, as a rational to create a # DateTime, or as both. # # If both a timestamp and rational are given, then the rational will only # be used if the timestamp falls outside of the range of Time on the # platform being used at runtime. # # DateTimes are created from the rational as follows: # # RubyCoreSupport.datetime_new!(RubyCoreSupport.rational_new!(numerator, denominator), 0, Date::ITALY) # # For performance reasons, the numerator and denominator must be specified # in their lowest form. def initialize(offset, previous_offset, numerator_or_timestamp, denominator_or_numerator = nil, denominator = nil) super(offset, previous_offset) if denominator numerator = denominator_or_numerator timestamp = numerator_or_timestamp elsif denominator_or_numerator numerator = numerator_or_timestamp denominator = denominator_or_numerator timestamp = nil else numerator = nil denominator = nil timestamp = numerator_or_timestamp end # Determine whether to use the timestamp or the numerator and denominator. if numerator && ( !timestamp || (timestamp < 0 && !RubyCoreSupport.time_supports_negative) || ((timestamp < -2147483648 || timestamp > 2147483647) && !RubyCoreSupport.time_supports_64bit) ) @numerator_or_time = numerator @denominator = denominator else @numerator_or_time = timestamp @denominator = nil end @at = nil end # A TimeOrDateTime instance representing the UTC time when this transition # occurs. def at # Thread-safety: It is possible that the value of @at may be calculated # multiple times in concurrently executing threads. It is not worth the # overhead of locking to ensure that @at is only calculated once. unless @at unless @denominator @at = TimeOrDateTime.new(@numerator_or_time) else r = RubyCoreSupport.rational_new!(@numerator_or_time, @denominator) dt = RubyCoreSupport.datetime_new!(r, 0, Date::ITALY) @at = TimeOrDateTime.new(dt) end end @at end # Returns true if this TimezoneTransitionDefinition is equal to the given # TimezoneTransitionDefinition. Two TimezoneTransitionDefinition instances # are considered to be equal by eql? if offset, previous_offset, # numerator_or_time and denominator are all equal. def eql?(tti) tti.kind_of?(TimezoneTransitionDefinition) && offset == tti.offset && previous_offset == tti.previous_offset && numerator_or_time == tti.numerator_or_time && denominator == tti.denominator end # Returns a hash of this TimezoneTransitionDefinition instance. def hash @offset.hash ^ @previous_offset.hash ^ @numerator_or_time.hash ^ @denominator.hash end end end tzinfo-1.2.2/lib/tzinfo/offset_rationals.rb0000644000004100000410000000722012400401360021012 0ustar www-datawww-datarequire 'rational' unless defined?(Rational) module TZInfo # Provides a method for getting Rationals for a timezone offset in seconds. # Pre-reduced rationals are returned for all the half-hour intervals between # -14 and +14 hours to avoid having to call gcd at runtime. # # @private module OffsetRationals #:nodoc: @@rational_cache = { -50400 => RubyCoreSupport.rational_new!(-7,12), -48600 => RubyCoreSupport.rational_new!(-9,16), -46800 => RubyCoreSupport.rational_new!(-13,24), -45000 => RubyCoreSupport.rational_new!(-25,48), -43200 => RubyCoreSupport.rational_new!(-1,2), -41400 => RubyCoreSupport.rational_new!(-23,48), -39600 => RubyCoreSupport.rational_new!(-11,24), -37800 => RubyCoreSupport.rational_new!(-7,16), -36000 => RubyCoreSupport.rational_new!(-5,12), -34200 => RubyCoreSupport.rational_new!(-19,48), -32400 => RubyCoreSupport.rational_new!(-3,8), -30600 => RubyCoreSupport.rational_new!(-17,48), -28800 => RubyCoreSupport.rational_new!(-1,3), -27000 => RubyCoreSupport.rational_new!(-5,16), -25200 => RubyCoreSupport.rational_new!(-7,24), -23400 => RubyCoreSupport.rational_new!(-13,48), -21600 => RubyCoreSupport.rational_new!(-1,4), -19800 => RubyCoreSupport.rational_new!(-11,48), -18000 => RubyCoreSupport.rational_new!(-5,24), -16200 => RubyCoreSupport.rational_new!(-3,16), -14400 => RubyCoreSupport.rational_new!(-1,6), -12600 => RubyCoreSupport.rational_new!(-7,48), -10800 => RubyCoreSupport.rational_new!(-1,8), -9000 => RubyCoreSupport.rational_new!(-5,48), -7200 => RubyCoreSupport.rational_new!(-1,12), -5400 => RubyCoreSupport.rational_new!(-1,16), -3600 => RubyCoreSupport.rational_new!(-1,24), -1800 => RubyCoreSupport.rational_new!(-1,48), 0 => RubyCoreSupport.rational_new!(0,1), 1800 => RubyCoreSupport.rational_new!(1,48), 3600 => RubyCoreSupport.rational_new!(1,24), 5400 => RubyCoreSupport.rational_new!(1,16), 7200 => RubyCoreSupport.rational_new!(1,12), 9000 => RubyCoreSupport.rational_new!(5,48), 10800 => RubyCoreSupport.rational_new!(1,8), 12600 => RubyCoreSupport.rational_new!(7,48), 14400 => RubyCoreSupport.rational_new!(1,6), 16200 => RubyCoreSupport.rational_new!(3,16), 18000 => RubyCoreSupport.rational_new!(5,24), 19800 => RubyCoreSupport.rational_new!(11,48), 21600 => RubyCoreSupport.rational_new!(1,4), 23400 => RubyCoreSupport.rational_new!(13,48), 25200 => RubyCoreSupport.rational_new!(7,24), 27000 => RubyCoreSupport.rational_new!(5,16), 28800 => RubyCoreSupport.rational_new!(1,3), 30600 => RubyCoreSupport.rational_new!(17,48), 32400 => RubyCoreSupport.rational_new!(3,8), 34200 => RubyCoreSupport.rational_new!(19,48), 36000 => RubyCoreSupport.rational_new!(5,12), 37800 => RubyCoreSupport.rational_new!(7,16), 39600 => RubyCoreSupport.rational_new!(11,24), 41400 => RubyCoreSupport.rational_new!(23,48), 43200 => RubyCoreSupport.rational_new!(1,2), 45000 => RubyCoreSupport.rational_new!(25,48), 46800 => RubyCoreSupport.rational_new!(13,24), 48600 => RubyCoreSupport.rational_new!(9,16), 50400 => RubyCoreSupport.rational_new!(7,12)}.freeze # Returns a Rational expressing the fraction of a day that offset in # seconds represents (i.e. equivalent to Rational(offset, 86400)). def rational_for_offset(offset) @@rational_cache[offset] || Rational(offset, 86400) end module_function :rational_for_offset end end tzinfo-1.2.2/lib/tzinfo/ruby_core_support.rb0000644000004100000410000001111112400401360021227 0ustar www-datawww-datarequire 'date' require 'rational' unless defined?(Rational) module TZInfo # Methods to support different versions of Ruby. # # @private module RubyCoreSupport #:nodoc: # Use Rational.new! for performance reasons in Ruby 1.8. # This has been removed from 1.9, but Rational performs better. if Rational.respond_to? :new! def self.rational_new!(numerator, denominator = 1) Rational.new!(numerator, denominator) end else def self.rational_new!(numerator, denominator = 1) Rational(numerator, denominator) end end # Ruby 1.8.6 introduced new! and deprecated new0. # Ruby 1.9.0 removed new0. # Ruby trunk revision 31668 removed the new! method. # Still support new0 for better performance on older versions of Ruby (new0 indicates # that the rational has already been reduced to its lowest terms). # Fallback to jd with conversion from ajd if new! and new0 are unavailable. if DateTime.respond_to? :new! def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) DateTime.new!(ajd, of, sg) end elsif DateTime.respond_to? :new0 def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) DateTime.new0(ajd, of, sg) end else HALF_DAYS_IN_DAY = rational_new!(1, 2) def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY) # Convert from an Astronomical Julian Day number to a civil Julian Day number. jd = ajd + of + HALF_DAYS_IN_DAY # Ruby trunk revision 31862 changed the behaviour of DateTime.jd so that it will no # longer accept a fractional civil Julian Day number if further arguments are specified. # Calculate the hours, minutes and seconds to pass to jd. jd_i = jd.to_i jd_i -= 1 if jd < 0 hours = (jd - jd_i) * 24 hours_i = hours.to_i minutes = (hours - hours_i) * 60 minutes_i = minutes.to_i seconds = (minutes - minutes_i) * 60 DateTime.jd(jd_i, hours_i, minutes_i, seconds, of, sg) end end # DateTime in Ruby 1.8.6 doesn't consider times within the 60th second to be # valid. When attempting to specify such a DateTime, subtract the fractional # part and then add it back later if Date.respond_to?(:valid_time?) && !Date.valid_time?(0, 0, rational_new!(59001, 1000)) # 0:0:59.001 def self.datetime_new(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=Date::ITALY) if !s.kind_of?(Integer) && s > 59 dt = DateTime.new(y, m, d, h, min, 59, of, sg) dt + (s - 59) / 86400 else DateTime.new(y, m, d, h, min, s, of, sg) end end else def self.datetime_new(y=-4712, m=1, d=1, h=0, min=0, s=0, of=0, sg=Date::ITALY) DateTime.new(y, m, d, h, min, s, of, sg) end end # Returns true if Time on the runtime platform supports Times defined # by negative 32-bit timestamps, otherwise false. begin Time.at(-1) Time.at(-2147483648) def self.time_supports_negative true end rescue ArgumentError def self.time_supports_negative false end end # Returns true if Time on the runtime platform supports Times defined by # 64-bit timestamps, otherwise false. begin Time.at(-2147483649) Time.at(2147483648) def self.time_supports_64bit true end rescue RangeError def self.time_supports_64bit false end end # Return the result of Time#nsec if it exists, otherwise return the # result of Time#usec * 1000. if Time.method_defined?(:nsec) def self.time_nsec(time) time.nsec end else def self.time_nsec(time) time.usec * 1000 end end # Call String#force_encoding if this version of Ruby has encoding support # otherwise treat as a no-op. if String.method_defined?(:force_encoding) def self.force_encoding(str, encoding) str.force_encoding(encoding) end else def self.force_encoding(str, encoding) str end end # Wrapper for File.open that supports passing hash options for specifying # encodings on Ruby 1.9+. The options are ignored on earlier versions of # Ruby. if RUBY_VERSION =~ /\A1\.[0-8]\./ def self.open_file(file_name, mode, opts, &block) File.open(file_name, mode, &block) end else def self.open_file(file_name, mode, opts, &block) File.open(file_name, mode, opts, &block) end end end end tzinfo-1.2.2/lib/tzinfo/time_or_datetime.rb0000644000004100000410000002446012400401360020767 0ustar www-datawww-datarequire 'date' require 'rational' unless defined?(Rational) require 'time' module TZInfo # Used by TZInfo internally to represent either a Time, DateTime or # an Integer timestamp (seconds since 1970-01-01 00:00:00). class TimeOrDateTime include Comparable # Constructs a new TimeOrDateTime. timeOrDateTime can be a Time, DateTime # or Integer. If using a Time or DateTime, any time zone information # is ignored. # # Integer timestamps must be within the range supported by Time on the # platform being used. def initialize(timeOrDateTime) @time = nil @datetime = nil @timestamp = nil if timeOrDateTime.is_a?(Time) @time = timeOrDateTime # Avoid using the slower Rational class unless necessary. nsec = RubyCoreSupport.time_nsec(@time) usec = nsec % 1000 == 0 ? nsec / 1000 : Rational(nsec, 1000) @time = Time.utc(@time.year, @time.mon, @time.mday, @time.hour, @time.min, @time.sec, usec) unless @time.utc? @orig = @time elsif timeOrDateTime.is_a?(DateTime) @datetime = timeOrDateTime @datetime = @datetime.new_offset(0) unless @datetime.offset == 0 @orig = @datetime else @timestamp = timeOrDateTime.to_i if !RubyCoreSupport.time_supports_64bit && (@timestamp > 2147483647 || @timestamp < -2147483648 || (@timestamp < 0 && !RubyCoreSupport.time_supports_negative)) raise RangeError, 'Timestamp is outside the supported range of Time on this platform' end @orig = @timestamp end end # Returns the time as a Time. # # When converting from a DateTime, the result is truncated to microsecond # precision. def to_time # Thread-safety: It is possible that the value of @time may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @time is only # calculated once. unless @time if @timestamp @time = Time.at(@timestamp).utc else @time = Time.utc(year, mon, mday, hour, min, sec, usec) end end @time end # Returns the time as a DateTime. # # When converting from a Time, the result is truncated to microsecond # precision. def to_datetime # Thread-safety: It is possible that the value of @datetime may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @datetime is only # calculated once. unless @datetime # Avoid using Rational unless necessary. u = usec s = u == 0 ? sec : Rational(sec * 1000000 + u, 1000000) @datetime = RubyCoreSupport.datetime_new(year, mon, mday, hour, min, s) end @datetime end # Returns the time as an integer timestamp. def to_i # Thread-safety: It is possible that the value of @timestamp may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @timestamp is only # calculated once. unless @timestamp @timestamp = to_time.to_i end @timestamp end # Returns the time as the original time passed to new. def to_orig @orig end # Returns a string representation of the TimeOrDateTime. def to_s if @orig.is_a?(Time) "Time: #{@orig.to_s}" elsif @orig.is_a?(DateTime) "DateTime: #{@orig.to_s}" else "Timestamp: #{@orig.to_s}" end end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #{@orig.inspect}>" end # Returns the year. def year if @time @time.year elsif @datetime @datetime.year else to_time.year end end # Returns the month of the year (1..12). def mon if @time @time.mon elsif @datetime @datetime.mon else to_time.mon end end alias :month :mon # Returns the day of the month (1..n). def mday if @time @time.mday elsif @datetime @datetime.mday else to_time.mday end end alias :day :mday # Returns the hour of the day (0..23). def hour if @time @time.hour elsif @datetime @datetime.hour else to_time.hour end end # Returns the minute of the hour (0..59). def min if @time @time.min elsif @datetime @datetime.min else to_time.min end end # Returns the second of the minute (0..60). (60 for a leap second). def sec if @time @time.sec elsif @datetime @datetime.sec else to_time.sec end end # Returns the number of microseconds for the time. def usec if @time @time.usec elsif @datetime # Ruby 1.8 has sec_fraction (of which the documentation says # 'I do NOT recommend you to use this method'). sec_fraction no longer # exists in Ruby 1.9. # Calculate the sec_fraction from the day_fraction. ((@datetime.day_fraction - OffsetRationals.rational_for_offset(@datetime.hour * 3600 + @datetime.min * 60 + @datetime.sec)) * 86400000000).to_i else 0 end end # Compares this TimeOrDateTime with another Time, DateTime, timestamp # (Integer) or TimeOrDateTime. Returns -1, 0 or +1 depending # whether the receiver is less than, equal to, or greater than # timeOrDateTime. # # Returns nil if the passed in timeOrDateTime is not comparable with # TimeOrDateTime instances. # # Comparisons involving a DateTime will be performed using DateTime#<=>. # Comparisons that don't involve a DateTime, but include a Time will be # performed with Time#<=>. Otherwise comparisons will be performed with # Integer#<=>. def <=>(timeOrDateTime) return nil unless timeOrDateTime.is_a?(TimeOrDateTime) || timeOrDateTime.is_a?(Time) || timeOrDateTime.is_a?(DateTime) || timeOrDateTime.respond_to?(:to_i) unless timeOrDateTime.is_a?(TimeOrDateTime) timeOrDateTime = TimeOrDateTime.wrap(timeOrDateTime) end orig = timeOrDateTime.to_orig if @orig.is_a?(DateTime) || orig.is_a?(DateTime) # If either is a DateTime, assume it is there for a reason # (i.e. for its larger range of acceptable values on 32-bit systems). to_datetime <=> timeOrDateTime.to_datetime elsif @orig.is_a?(Time) || orig.is_a?(Time) to_time <=> timeOrDateTime.to_time else to_i <=> timeOrDateTime.to_i end end # Adds a number of seconds to the TimeOrDateTime. Returns a new # TimeOrDateTime, preserving what the original constructed type was. # If the original type is a Time and the resulting calculation goes out of # range for Times, then an exception will be raised by the Time class. def +(seconds) if seconds == 0 self else if @orig.is_a?(DateTime) TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) else # + defined for Time and Integer TimeOrDateTime.new(@orig + seconds) end end end # Subtracts a number of seconds from the TimeOrDateTime. Returns a new # TimeOrDateTime, preserving what the original constructed type was. # If the original type is a Time and the resulting calculation goes out of # range for Times, then an exception will be raised by the Time class. def -(seconds) self + (-seconds) end # Similar to the + operator, but converts to a DateTime based TimeOrDateTime # where the Time or Integer timestamp to go out of the allowed range for a # Time, converts to a DateTime based TimeOrDateTime. # # Note that the range of Time varies based on the platform. def add_with_convert(seconds) if seconds == 0 self else if @orig.is_a?(DateTime) TimeOrDateTime.new(@orig + OffsetRationals.rational_for_offset(seconds)) else # A Time or timestamp. result = to_i + seconds if ((result > 2147483647 || result < -2147483648) && !RubyCoreSupport.time_supports_64bit) || (result < 0 && !RubyCoreSupport.time_supports_negative) result = TimeOrDateTime.new(to_datetime + OffsetRationals.rational_for_offset(seconds)) else result = TimeOrDateTime.new(@orig + seconds) end end end end # Returns true if todt represents the same time and was originally # constructed with the same type (DateTime, Time or timestamp) as this # TimeOrDateTime. def eql?(todt) todt.kind_of?(TimeOrDateTime) && to_orig.eql?(todt.to_orig) end # Returns a hash of this TimeOrDateTime. def hash @orig.hash end # If no block is given, returns a TimeOrDateTime wrapping the given # timeOrDateTime. If a block is specified, a TimeOrDateTime is constructed # and passed to the block. The result of the block must be a TimeOrDateTime. # # The result of the block will be converted to the type of the originally # passed in timeOrDateTime and then returned as the result of wrap. # # timeOrDateTime can be a Time, DateTime, timestamp (Integer) or # TimeOrDateTime. If a TimeOrDateTime is passed in, no new TimeOrDateTime # will be constructed and the value passed to wrap will be used when # calling the block. def self.wrap(timeOrDateTime) t = timeOrDateTime.is_a?(TimeOrDateTime) ? timeOrDateTime : TimeOrDateTime.new(timeOrDateTime) if block_given? t = yield t if timeOrDateTime.is_a?(TimeOrDateTime) t elsif timeOrDateTime.is_a?(Time) t.to_time elsif timeOrDateTime.is_a?(DateTime) t.to_datetime else t.to_i end else t end end end end tzinfo-1.2.2/lib/tzinfo/info_timezone.rb0000644000004100000410000000107312400401360020315 0ustar www-datawww-datamodule TZInfo # A Timezone based on a TimezoneInfo. # # @private class InfoTimezone < Timezone #:nodoc: # Constructs a new InfoTimezone with a TimezoneInfo instance. def self.new(info) tz = super() tz.send(:setup, info) tz end # The identifier of the timezone, e.g. "Europe/Paris". def identifier @info.identifier end protected # The TimezoneInfo for this Timezone. def info @info end def setup(info) @info = info end end end tzinfo-1.2.2/lib/tzinfo/zoneinfo_data_source.rb0000644000004100000410000004603412400401360021656 0ustar www-datawww-datamodule TZInfo # An InvalidZoneinfoDirectory exception is raised if the DataSource is # set to a specific zoneinfo path, which is not a valid zoneinfo directory # (i.e. a directory containing index files named iso3166.tab and zone.tab # as well as other timezone files). class InvalidZoneinfoDirectory < StandardError end # A ZoneinfoDirectoryNotFound exception is raised if no valid zoneinfo # directory could be found when checking the paths listed in # ZoneinfoDataSource.search_path. A valid zoneinfo directory is one that # contains timezone files, a country code index file named iso3166.tab and a # timezone index file named zone1970.tab or zone.tab. class ZoneinfoDirectoryNotFound < StandardError end # A DataSource that loads data from a 'zoneinfo' directory containing # compiled "TZif" version 3 (or earlier) files in addition to iso3166.tab and # zone1970.tab or zone.tab index files. # # To have TZInfo load the system zoneinfo files, call TZInfo::DataSource.set # as follows: # # TZInfo::DataSource.set(:zoneinfo) # # To load zoneinfo files from a particular directory, pass the directory to # TZInfo::DataSource.set: # # TZInfo::DataSource.set(:zoneinfo, directory) # # Note that the platform used at runtime may limit the range of available # transition data that can be loaded from zoneinfo files. There are two # factors to consider: # # First of all, the zoneinfo support in TZInfo makes use of Ruby's Time class. # On 32-bit builds of Ruby 1.8, the Time class only supports 32-bit # timestamps. This means that only Times between 1901-12-13 20:45:52 and # 2038-01-19 03:14:07 can be represented. Furthermore, certain platforms only # allow for positive 32-bit timestamps (notably Windows), making the earliest # representable time 1970-01-01 00:00:00. # # 64-bit builds of Ruby 1.8 and all builds of Ruby 1.9 support 64-bit # timestamps. This means that there is no practical restriction on the range # of the Time class on these platforms. # # TZInfo will only load transitions that fall within the supported range of # the Time class. Any queries performed on times outside of this range may # give inaccurate results. # # The second factor concerns the zoneinfo files. Versions of the 'zic' tool # (used to build zoneinfo files) that were released prior to February 2006 # created zoneinfo files that used 32-bit integers for transition timestamps. # Later versions of zic produce zoneinfo files that use 64-bit integers. If # you have 32-bit zoneinfo files on your system, then any queries falling # outside of the range 1901-12-13 20:45:52 to 2038-01-19 03:14:07 may be # inaccurate. # # Most modern platforms include 64-bit zoneinfo files. However, Mac OS X (up # to at least 10.8.4) still uses 32-bit zoneinfo files. # # To check whether your zoneinfo files contain 32-bit or 64-bit transition # data, you can run the following code (substituting the identifier of the # zone you want to test for zone_identifier): # # TZInfo::DataSource.set(:zoneinfo) # dir = TZInfo::DataSource.get.zoneinfo_dir # File.open(File.join(dir, zone_identifier), 'r') {|f| f.read(5) } # # If the last line returns "TZif\\x00", then you have a 32-bit zoneinfo file. # If it returns "TZif2" or "TZif3" then you have a 64-bit zoneinfo file. # # If you require support for 64-bit transitions, but are restricted to 32-bit # zoneinfo support, then you may want to consider using TZInfo::RubyDataSource # instead. class ZoneinfoDataSource < DataSource # The default value of ZoneinfoDataSource.search_path. DEFAULT_SEARCH_PATH = ['/usr/share/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo'].freeze # The default value of ZoneinfoDataSource.alternate_iso3166_tab_search_path. DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH = ['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166'].freeze # Paths to be checked to find the system zoneinfo directory. @@search_path = DEFAULT_SEARCH_PATH.dup # Paths to possible alternate iso3166.tab files (used to locate the # system-wide iso3166.tab files on FreeBSD and OpenBSD). @@alternate_iso3166_tab_search_path = DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH.dup # An Array of directories that will be checked to find the system zoneinfo # directory. # # Directories are checked in the order they appear in the Array. # # The default value is ['/usr/share/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo']. def self.search_path @@search_path end # Sets the directories to be checked when locating the system zoneinfo # directory. # # Can be set to an Array of directories or a String containing directories # separated with File::PATH_SEPARATOR. # # Directories are checked in the order they appear in the Array or String. # # Set to nil to revert to the default paths. def self.search_path=(search_path) @@search_path = process_search_path(search_path, DEFAULT_SEARCH_PATH) end # An Array of paths that will be checked to find an alternate iso3166.tab # file if one was not included in the zoneinfo directory (for example, on # FreeBSD and OpenBSD systems). # # Paths are checked in the order they appear in the array. # # The default value is ['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166']. def self.alternate_iso3166_tab_search_path @@alternate_iso3166_tab_search_path end # Sets the paths to check to locate an alternate iso3166.tab file if one was # not included in the zoneinfo directory. # # Can be set to an Array of directories or a String containing directories # separated with File::PATH_SEPARATOR. # # Paths are checked in the order they appear in the array. # # Set to nil to revert to the default paths. def self.alternate_iso3166_tab_search_path=(alternate_iso3166_tab_search_path) @@alternate_iso3166_tab_search_path = process_search_path(alternate_iso3166_tab_search_path, DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH) end # The zoneinfo directory being used. attr_reader :zoneinfo_dir # Creates a new ZoneinfoDataSource. # # If zoneinfo_dir is specified, it will be checked and used as the source # of zoneinfo files. # # The directory must contain a file named iso3166.tab and a file named # either zone1970.tab or zone.tab. These may either be included in the root # of the directory or in a 'tab' sub-directory and named 'country.tab' and # 'zone_sun.tab' respectively (as is the case on Solaris. # # Additionally, the path to iso3166.tab can be overridden using the # alternate_iso3166_tab_path parameter. # # InvalidZoneinfoDirectory will be raised if the iso3166.tab and # zone1970.tab or zone.tab files cannot be found using the zoneinfo_dir and # alternate_iso3166_tab_path parameters. # # If zoneinfo_dir is not specified or nil, the paths referenced in # search_path are searched in order to find a valid zoneinfo directory # (one that contains zone1970.tab or zone.tab and iso3166.tab files as # above). # # The paths referenced in alternate_iso3166_tab_search_path are also # searched to find an iso3166.tab file if one of the searched zoneinfo # directories doesn't contain an iso3166.tab file. # # If no valid directory can be found by searching, ZoneinfoDirectoryNotFound # will be raised. def initialize(zoneinfo_dir = nil, alternate_iso3166_tab_path = nil) if zoneinfo_dir iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(zoneinfo_dir, alternate_iso3166_tab_path) unless iso3166_tab_path && zone_tab_path raise InvalidZoneinfoDirectory, "#{zoneinfo_dir} is not a directory or doesn't contain a iso3166.tab file and a zone1970.tab or zone.tab file." end @zoneinfo_dir = zoneinfo_dir else @zoneinfo_dir, iso3166_tab_path, zone_tab_path = find_zoneinfo_dir unless @zoneinfo_dir && iso3166_tab_path && zone_tab_path raise ZoneinfoDirectoryNotFound, "None of the paths included in TZInfo::ZoneinfoDataSource.search_path are valid zoneinfo directories." end end @zoneinfo_dir = File.expand_path(@zoneinfo_dir).freeze @timezone_index = load_timezone_index.freeze @country_index = load_country_index(iso3166_tab_path, zone_tab_path).freeze end # Returns a TimezoneInfo instance for a given identifier. # Raises InvalidTimezoneIdentifier if the timezone is not found or the # identifier is invalid. def load_timezone_info(identifier) begin if @timezone_index.include?(identifier) path = File.join(@zoneinfo_dir, identifier) # Untaint path rather than identifier. We don't want to modify # identifier. identifier may also be frozen and therefore cannot be # untainted. path.untaint begin ZoneinfoTimezoneInfo.new(identifier, path) rescue InvalidZoneinfoFile => e raise InvalidTimezoneIdentifier, e.message end else raise InvalidTimezoneIdentifier, 'Invalid identifier' end rescue Errno::ENOENT, Errno::ENAMETOOLONG, Errno::ENOTDIR raise InvalidTimezoneIdentifier, 'Invalid identifier' rescue Errno::EACCES => e raise InvalidTimezoneIdentifier, e.message end end # Returns an array of all the available timezone identifiers. def timezone_identifiers @timezone_index end # Returns an array of all the available timezone identifiers for # data timezones (i.e. those that actually contain definitions). # # For ZoneinfoDataSource, this will always be identical to # timezone_identifers. def data_timezone_identifiers @timezone_index end # Returns an array of all the available timezone identifiers that # are links to other timezones. # # For ZoneinfoDataSource, this will always be an empty array. def linked_timezone_identifiers [].freeze end # Returns a CountryInfo instance for the given ISO 3166-1 alpha-2 # country code. Raises InvalidCountryCode if the country could not be found # or the code is invalid. def load_country_info(code) info = @country_index[code] raise InvalidCountryCode, 'Invalid country code' unless info info end # Returns an array of all the available ISO 3166-1 alpha-2 # country codes. def country_codes @country_index.keys.freeze end # Returns the name and information about this DataSource. def to_s "Zoneinfo DataSource: #{@zoneinfo_dir}" end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #{@zoneinfo_dir}>" end private # Processes a path for use as the search_path or # alternate_iso3166_tab_search_path. def self.process_search_path(path, default) if path if path.kind_of?(String) path.split(File::PATH_SEPARATOR) else path.collect {|p| p.to_s} end else default.dup end end # Validates a zoneinfo directory and returns the paths to the iso3166.tab # and zone1970.tab or zone.tab files if valid. If the directory is not # valid, returns nil. # # The path to the iso3166.tab file may be overriden by passing in a path. # This is treated as either absolute or relative to the current working # directory. def validate_zoneinfo_dir(path, iso3166_tab_path = nil) if File.directory?(path) if iso3166_tab_path return nil unless File.file?(iso3166_tab_path) else iso3166_tab_path = resolve_tab_path(path, ['iso3166.tab'], 'country.tab') return nil unless iso3166_tab_path end zone_tab_path = resolve_tab_path(path, ['zone1970.tab', 'zone.tab'], 'zone_sun.tab') return nil unless zone_tab_path [iso3166_tab_path, zone_tab_path] else nil end end # Attempts to resolve the path to a tab file given its standard names and # tab sub-directory name (as used on Solaris). def resolve_tab_path(zoneinfo_path, standard_names, tab_name) standard_names.each do |standard_name| path = File.join(zoneinfo_path, standard_name) return path if File.file?(path) end path = File.join(zoneinfo_path, 'tab', tab_name) return path if File.file?(path) nil end # Finds a zoneinfo directory using search_path and # alternate_iso3166_tab_search_path. Returns the paths to the directory, # the iso3166.tab file and the zone.tab file or nil if not found. def find_zoneinfo_dir alternate_iso3166_tab_path = self.class.alternate_iso3166_tab_search_path.detect do |path| File.file?(path) end self.class.search_path.each do |path| # Try without the alternate_iso3166_tab_path first. iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(path) return path, iso3166_tab_path, zone_tab_path if iso3166_tab_path && zone_tab_path if alternate_iso3166_tab_path iso3166_tab_path, zone_tab_path = validate_zoneinfo_dir(path, alternate_iso3166_tab_path) return path, iso3166_tab_path, zone_tab_path if iso3166_tab_path && zone_tab_path end end # Not found. nil end # Scans @zoneinfo_dir and returns an Array of available timezone # identifiers. def load_timezone_index index = [] # Ignoring particular files: # +VERSION is included on Mac OS X. # localtime current local timezone (may be a link). # posix, posixrules and right are directories containing other versions of the zoneinfo files. # src is a directory containing the tzdata source included on Solaris. # Factory is the compiled in default timezone. enum_timezones(nil, ['+VERSION', 'localtime', 'posix', 'posixrules', 'right', 'src', 'Factory']) do |identifier| index << identifier end index.sort end # Recursively scans a directory of timezones, calling the passed in block # for each identifier found. def enum_timezones(dir, exclude = [], &block) Dir.foreach(dir ? File.join(@zoneinfo_dir, dir) : @zoneinfo_dir) do |entry| unless entry =~ /\./ || exclude.include?(entry) entry.untaint path = dir ? File.join(dir, entry) : entry full_path = File.join(@zoneinfo_dir, path) if File.directory?(full_path) enum_timezones(path, [], &block) elsif File.file?(full_path) yield path end end end end # Uses the iso3166.tab and zone1970.tab or zone.tab files to build an index # of the available countries and their timezones. def load_country_index(iso3166_tab_path, zone_tab_path) # Handle standard 3 to 4 column zone.tab files as well as the 4 to 5 # column format used by Solaris. # # On Solaris, an extra column before the comment gives an optional # linked/alternate timezone identifier (or '-' if not set). # # Additionally, there is a section at the end of the file for timezones # covering regions. These are given lower-case "country" codes. The timezone # identifier column refers to a continent instead of an identifier. These # lines will be ignored by TZInfo. # # Since the last column is optional in both formats, testing for the # Solaris format is done in two passes. The first pass identifies if there # are any lines using 5 columns. # The first column is allowed to be a comma separated list of country # codes, as used in zone1970.tab (introduced in tzdata 2014f). # # The first country code in the comma-separated list is the country that # contains the city the zone identifer is based on. The first country # code on each line is considered to be primary with the others # secondary. # # The zones for each country are ordered primary first, then secondary. # Within the primary and secondary groups, the zones are ordered by their # order in the file. file_is_5_column = false zone_tab = [] RubyCoreSupport.open_file(zone_tab_path, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file| file.each_line do |line| line.chomp! if line =~ /\A([A-Z]{2}(?:,[A-Z]{2})*)\t(?:([+\-])(\d{2})(\d{2})([+\-])(\d{3})(\d{2})|([+\-])(\d{2})(\d{2})(\d{2})([+\-])(\d{3})(\d{2})(\d{2}))\t([^\t]+)(?:\t([^\t]+))?(?:\t([^\t]+))?\z/ codes = $1 if $2 latitude = dms_to_rational($2, $3, $4) longitude = dms_to_rational($5, $6, $7) else latitude = dms_to_rational($8, $9, $10, $11) longitude = dms_to_rational($12, $13, $14, $15) end zone_identifier = $16 column4 = $17 column5 = $18 file_is_5_column = true if column5 zone_tab << [codes.split(','), zone_identifier, latitude, longitude, column4, column5] end end end primary_zones = {} secondary_zones = {} zone_tab.each do |codes, zone_identifier, latitude, longitude, column4, column5| description = file_is_5_column ? column5 : column4 country_timezone = CountryTimezone.new(zone_identifier, latitude, longitude, description) # codes will always have at least one element (primary_zones[codes.first] ||= []) << country_timezone codes[1..-1].each do |code| (secondary_zones[code] ||= []) << country_timezone end end countries = {} RubyCoreSupport.open_file(iso3166_tab_path, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file| file.each_line do |line| line.chomp! # Handle both the two column alpha-2 and name format used in the tz # database as well as the 4 column alpha-2, alpha-3, numeric-3 and # name format used by FreeBSD and OpenBSD. if line =~ /\A([A-Z]{2})(?:\t[A-Z]{3}\t[0-9]{3})?\t(.+)\z/ code = $1 name = $2 zones = (primary_zones[code] || []) + (secondary_zones[code] || []) countries[code] = ZoneinfoCountryInfo.new(code, name, zones) end end end countries end # Converts degrees, minutes and seconds to a Rational. def dms_to_rational(sign, degrees, minutes, seconds = nil) result = degrees.to_i + Rational(minutes.to_i, 60) result += Rational(seconds.to_i, 3600) if seconds result = -result if sign == '-' result end end end tzinfo-1.2.2/lib/tzinfo/timezone_proxy.rb0000644000004100000410000000471412400401360020550 0ustar www-datawww-datamodule TZInfo # A proxy class representing a timezone with a given identifier. TimezoneProxy # inherits from Timezone and can be treated like any Timezone loaded with # Timezone.get. # # The first time an attempt is made to access the data for the timezone, the # real Timezone is loaded. If the proxy's identifier was not valid, then an # exception will be raised at this point. class TimezoneProxy < Timezone # Construct a new TimezoneProxy for the given identifier. The identifier # is not checked when constructing the proxy. It will be validated on the # when the real Timezone is loaded. def self.new(identifier) # Need to override new to undo the behaviour introduced in Timezone#new. tzp = super() tzp.send(:setup, identifier) tzp end # The identifier of the timezone, e.g. "Europe/Paris". def identifier @real_timezone ? @real_timezone.identifier : @identifier end # Returns the TimezonePeriod for the given UTC time. utc can either be # a DateTime, Time or integer timestamp (Time.to_i). Any timezone # information in utc is ignored (it is treated as a UTC time). def period_for_utc(utc) real_timezone.period_for_utc(utc) end # Returns the set of TimezonePeriod instances that are valid for the given # local time as an array. If you just want a single period, use # period_for_local instead and specify how abiguities should be resolved. # Returns an empty array if no periods are found for the given time. def periods_for_local(local) real_timezone.periods_for_local(local) end # Returns the canonical zone for this Timezone. def canonical_zone real_timezone.canonical_zone end # Dumps this TimezoneProxy for marshalling. def _dump(limit) identifier end # Loads a marshalled TimezoneProxy. def self._load(data) TimezoneProxy.new(data) end private def setup(identifier) @identifier = identifier @real_timezone = nil end def real_timezone # Thread-safety: It is possible that the value of @real_timezone may be # calculated multiple times in concurrently executing threads. It is not # worth the overhead of locking to ensure that @real_timezone is only # calculated once. @real_timezone ||= Timezone.get(@identifier) end end end tzinfo-1.2.2/lib/tzinfo/timezone_index_definition.rb0000644000004100000410000000314412400401360022702 0ustar www-datawww-datamodule TZInfo # The timezone index file includes TimezoneIndexDefinition which provides # methods used to define timezones in the index. # # @private module TimezoneIndexDefinition #:nodoc: # Add class methods to the includee and initialize class instance variables. def self.append_features(base) super base.extend(ClassMethods) base.instance_eval do @timezones = [] @data_timezones = [] @linked_timezones = [] end end # Class methods for inclusion. # # @private module ClassMethods #:nodoc: # Defines a timezone based on data. def timezone(identifier) @timezones << identifier @data_timezones << identifier end # Defines a timezone which is a link to another timezone. def linked_timezone(identifier) @timezones << identifier @linked_timezones << identifier end # Returns a frozen array containing the identifiers of all the timezones. # Identifiers appear in the order they were defined in the index. def timezones @timezones.freeze end # Returns a frozen array containing the identifiers of all data timezones. # Identifiers appear in the order they were defined in the index. def data_timezones @data_timezones.freeze end # Returns a frozen array containing the identifiers of all linked # timezones. Identifiers appear in the order they were defined in # the index. def linked_timezones @linked_timezones.freeze end end end end tzinfo-1.2.2/lib/tzinfo/linked_timezone_info.rb0000644000004100000410000000150312400401360021641 0ustar www-datawww-datamodule TZInfo # Represents a timezone that is defined as a link or alias to another zone. class LinkedTimezoneInfo < TimezoneInfo # The zone that provides the data (that this zone is an alias for). attr_reader :link_to_identifier # Constructs a new LinkedTimezoneInfo with an identifier and the identifier # of the zone linked to. def initialize(identifier, link_to_identifier) super(identifier) @link_to_identifier = link_to_identifier end # Returns internal object state as a programmer-readable string. def inspect "#<#{self.class}: #@identifier,#@link_to_identifier>" end # Constructs a Timezone instance for the timezone represented by this # DataTimezoneInfo. def create_timezone LinkedTimezone.new(self) end end end tzinfo-1.2.2/lib/tzinfo/ruby_data_source.rb0000644000004100000410000001022612400401360021002 0ustar www-datawww-datamodule TZInfo # A DataSource that loads data from the set of Ruby modules included in the # TZInfo::Data library (tzinfo-data gem). # # To have TZInfo use this DataSource, call TZInfo::DataSource.set as follows: # # TZInfo::DataSource.set(:ruby) class RubyDataSource < DataSource # Base path for require. REQUIRE_PATH = File.join('tzinfo', 'data', 'definitions') # Whether the timezone index has been loaded yet. @@timezone_index_loaded = false # Whether the country index has been loaded yet. @@country_index_loaded = false # Returns a TimezoneInfo instance for a given identifier. # Raises InvalidTimezoneIdentifier if the timezone is not found or the # identifier is invalid. def load_timezone_info(identifier) raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier !~ /^[A-Za-z0-9\+\-_]+(\/[A-Za-z0-9\+\-_]+)*$/ identifier = identifier.gsub(/-/, '__m__').gsub(/\+/, '__p__') # Untaint identifier after it has been reassigned to a new string. We # don't want to modify the original identifier. identifier may also be # frozen and therefore cannot be untainted. identifier.untaint identifier = identifier.split('/') begin require_definition(identifier) m = Data::Definitions identifier.each {|part| m = m.const_get(part) } m.get rescue LoadError, NameError => e raise InvalidTimezoneIdentifier, e.message end end # Returns an array of all the available timezone identifiers. def timezone_identifiers load_timezone_index Data::Indexes::Timezones.timezones end # Returns an array of all the available timezone identifiers for # data timezones (i.e. those that actually contain definitions). def data_timezone_identifiers load_timezone_index Data::Indexes::Timezones.data_timezones end # Returns an array of all the available timezone identifiers that # are links to other timezones. def linked_timezone_identifiers load_timezone_index Data::Indexes::Timezones.linked_timezones end # Returns a CountryInfo instance for the given ISO 3166-1 alpha-2 # country code. Raises InvalidCountryCode if the country could not be found # or the code is invalid. def load_country_info(code) load_country_index info = Data::Indexes::Countries.countries[code] raise InvalidCountryCode, 'Invalid country code' unless info info end # Returns an array of all the available ISO 3166-1 alpha-2 # country codes. def country_codes load_country_index Data::Indexes::Countries.countries.keys.freeze end # Returns the name of this DataSource. def to_s "Ruby DataSource" end private # Requires a zone definition by its identifier (split on /). def require_definition(identifier) require_data(*(['definitions'] + identifier)) end # Requires an index by its name. def self.require_index(name) require_data(*['indexes', name]) end # Requires a file from tzinfo/data. def require_data(*file) self.class.require_data(*file) end # Requires a file from tzinfo/data. def self.require_data(*file) require File.join('tzinfo', 'data', *file) end # Loads in the index of timezones if it hasn't already been loaded. def load_timezone_index self.class.load_timezone_index end # Loads in the index of timezones if it hasn't already been loaded. def self.load_timezone_index unless @@timezone_index_loaded require_index('timezones') @@timezone_index_loaded = true end end # Loads in the index of countries if it hasn't already been loaded. def load_country_index self.class.load_country_index end # Loads in the index of countries if it hasn't already been loaded. def self.load_country_index unless @@country_index_loaded require_index('countries') @@country_index_loaded = true end end end end tzinfo-1.2.2/metadata.yml0000644000004100000410000001426712400401360015360 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: tzinfo version: !ruby/object:Gem::Version version: 1.2.2 platform: ruby authors: - Philip Ross autorequire: bindir: bin cert_chain: - | -----BEGIN CERTIFICATE----- MIIDdDCCAlygAwIBAgIBATANBgkqhkiG9w0BAQUFADBAMRIwEAYDVQQDDAlwaGls LnJvc3MxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv bTAeFw0xMzA5MjUyMTA0NTNaFw0xNDA5MjUyMTA0NTNaMEAxEjAQBgNVBAMMCXBo aWwucm9zczEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYD Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkZzB+qfhmyY+XRvU u310LMTGsTkR4/8JFCMF0YeQX6ZKmLr1fKzF3At1+DlI+v0t/G2FS6Dic0V3l8MK JczyFh72NANOaQhAo0GHh8WkaeCf2DLL5K6YJeLpvkvp39oxzn00A4zosnzxM50f Xrjx2HmurcJQurzafeCDj67QccaNE+5H+mcIVAJlsA1h1f5QFZ3SqQ4mf8St40pE 6YR4ev/Eq6Hb8aUoUq30otxbeHAEHh8cdVhTNFq7sPWb0psQRF2D/+o0MLgHt8PY EUm49szlLsnjVXAMCHU7wH9CmDR/5Lzcrgqh3DgyI8ay6DnlSQ213eYZH/Nkn1Yz TcNLCQIDAQABo3kwdzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU D5nzO9/MG4B6ygch/Pv6PF9Q5x8wHgYDVR0RBBcwFYETcGhpbC5yb3NzQGdtYWls LmNvbTAeBgNVHRIEFzAVgRNwaGlsLnJvc3NAZ21haWwuY29tMA0GCSqGSIb3DQEB BQUAA4IBAQAKZJXA++aLjISMKZea4PmXuH93YbMxoyBby3SRfwvLh7cBMEiCy5fu xYR46qa9ixC6JyVuxAWA2AGHLOqabKkq6AxntqIk1OAnZGBNRuCnLYzSx+6YDjaY ZcAmqPdS0Adj+1lNc+MgHiMrMLimNO4Cur4w4zYNZFvQan78WtLnwiaYPM2Tke1B UVjGvQVkM6gVIVH3937au2iHpJAehbhkEbgM02knNemiNwi58j7pMS9MhelxJxdz fs7XSYlwQp0zY7PFSMwJeBpQFDBnShcweRQ+0QdUUS4FHrwfXex0QsXp9UROUX+4 6BVw9ZDNFnDH4PQjZGbdwanB7kzm+TEi -----END CERTIFICATE----- date: 2014-08-08 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: thread_safe requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '0.1' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '0.1' description: TZInfo provides daylight savings aware transformations between times in different time zones. email: phil.ross@gmail.com executables: [] extensions: [] extra_rdoc_files: - README.md - CHANGES.md - LICENSE files: - ".yardopts" - CHANGES.md - LICENSE - README.md - Rakefile - lib/tzinfo.rb - lib/tzinfo/country.rb - lib/tzinfo/country_index_definition.rb - lib/tzinfo/country_info.rb - lib/tzinfo/country_timezone.rb - lib/tzinfo/data_source.rb - lib/tzinfo/data_timezone.rb - lib/tzinfo/data_timezone_info.rb - lib/tzinfo/info_timezone.rb - lib/tzinfo/linked_timezone.rb - lib/tzinfo/linked_timezone_info.rb - lib/tzinfo/offset_rationals.rb - lib/tzinfo/ruby_core_support.rb - lib/tzinfo/ruby_country_info.rb - lib/tzinfo/ruby_data_source.rb - lib/tzinfo/time_or_datetime.rb - lib/tzinfo/timezone.rb - lib/tzinfo/timezone_definition.rb - lib/tzinfo/timezone_index_definition.rb - lib/tzinfo/timezone_info.rb - lib/tzinfo/timezone_offset.rb - lib/tzinfo/timezone_period.rb - lib/tzinfo/timezone_proxy.rb - lib/tzinfo/timezone_transition.rb - lib/tzinfo/timezone_transition_definition.rb - lib/tzinfo/transition_data_timezone_info.rb - lib/tzinfo/zoneinfo_country_info.rb - lib/tzinfo/zoneinfo_data_source.rb - lib/tzinfo/zoneinfo_timezone_info.rb - test/tc_country.rb - test/tc_country_index_definition.rb - test/tc_country_info.rb - test/tc_country_timezone.rb - test/tc_data_source.rb - test/tc_data_timezone.rb - test/tc_data_timezone_info.rb - test/tc_info_timezone.rb - test/tc_linked_timezone.rb - test/tc_linked_timezone_info.rb - test/tc_offset_rationals.rb - test/tc_ruby_core_support.rb - test/tc_ruby_country_info.rb - test/tc_ruby_data_source.rb - test/tc_time_or_datetime.rb - test/tc_timezone.rb - test/tc_timezone_definition.rb - test/tc_timezone_index_definition.rb - test/tc_timezone_info.rb - test/tc_timezone_london.rb - test/tc_timezone_melbourne.rb - test/tc_timezone_new_york.rb - test/tc_timezone_offset.rb - test/tc_timezone_period.rb - test/tc_timezone_proxy.rb - test/tc_timezone_transition.rb - test/tc_timezone_transition_definition.rb - test/tc_timezone_utc.rb - test/tc_transition_data_timezone_info.rb - test/tc_zoneinfo_country_info.rb - test/tc_zoneinfo_data_source.rb - test/tc_zoneinfo_timezone_info.rb - test/test_utils.rb - test/ts_all.rb - test/ts_all_ruby.rb - test/ts_all_zoneinfo.rb - test/tzinfo-data/tzinfo/data.rb - test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb - test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb - test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb - test/tzinfo-data/tzinfo/data/definitions/EST.rb - test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb - test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb - test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb - test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb - test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb - test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb - test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb - test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb - test/tzinfo-data/tzinfo/data/definitions/UTC.rb - test/tzinfo-data/tzinfo/data/indexes/countries.rb - test/tzinfo-data/tzinfo/data/indexes/timezones.rb - test/tzinfo-data/tzinfo/data/version.rb - test/zoneinfo/America/Argentina/Buenos_Aires - test/zoneinfo/America/New_York - test/zoneinfo/Australia/Melbourne - test/zoneinfo/EST - test/zoneinfo/Etc/UTC - test/zoneinfo/Europe/Amsterdam - test/zoneinfo/Europe/Andorra - test/zoneinfo/Europe/London - test/zoneinfo/Europe/Paris - test/zoneinfo/Europe/Prague - test/zoneinfo/Factory - test/zoneinfo/iso3166.tab - test/zoneinfo/posix/Europe/London - test/zoneinfo/posixrules - test/zoneinfo/right/Europe/London - test/zoneinfo/zone.tab - test/zoneinfo/zone1970.tab - tzinfo.gemspec homepage: http://tzinfo.github.io licenses: - MIT metadata: {} post_install_message: rdoc_options: - "--title" - TZInfo - "--main" - README.md require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 1.8.7 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: Daylight savings aware timezone library test_files: [] tzinfo-1.2.2/test/0000755000004100000410000000000012400401360014022 5ustar www-datawww-datatzinfo-1.2.2/test/tc_ruby_data_source.rb0000644000004100000410000000760412400401360020376 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCRubyDataSource < Minitest::Test def setup @data_source = RubyDataSource.new end def test_load_timezone_info_data info = @data_source.load_timezone_info('Europe/London') assert_kind_of(DataTimezoneInfo, info) assert_equal('Europe/London', info.identifier) end def test_load_timezone_info_linked info = @data_source.load_timezone_info('UTC') assert_kind_of(LinkedTimezoneInfo, info) assert_equal('UTC', info.identifier) assert_equal('Etc/UTC', info.link_to_identifier) end def test_load_timezone_info_does_not_exist assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('Nowhere/Special') end end def test_load_timezone_info_invalid assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('../Definitions/UTC') end end def test_load_timezone_info_nil assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info(nil) end end def test_load_timezone_info_case assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('europe/london') end end def test_load_timezone_info_plus info = @data_source.load_timezone_info('Etc/GMT+1') assert_equal('Etc/GMT+1', info.identifier) end def test_load_timezone_info_minus info = @data_source.load_timezone_info('Etc/GMT-1') assert_equal('Etc/GMT-1', info.identifier) end def test_load_timezone_info_tainted safe_test do identifier = 'Europe/Amsterdam'.taint assert(identifier.tainted?) info = @data_source.load_timezone_info(identifier) assert_equal('Europe/Amsterdam', info.identifier) assert(identifier.tainted?) end end def test_load_timezone_info_tainted_and_frozen safe_test do info = @data_source.load_timezone_info('Europe/Amsterdam'.taint.freeze) assert_equal('Europe/Amsterdam', info.identifier) end end def test_timezone_identifiers all = @data_source.timezone_identifiers assert_equal(TZInfo::Data::Indexes::Timezones.timezones, all) assert_equal(true, all.frozen?) end def test_data_timezone_identifiers all_data = @data_source.data_timezone_identifiers assert_equal(TZInfo::Data::Indexes::Timezones.data_timezones, all_data) assert_equal(true, all_data.frozen?) end def test_linked_timezone_identifiers all_linked = @data_source.linked_timezone_identifiers assert_equal(TZInfo::Data::Indexes::Timezones.linked_timezones, all_linked) assert_equal(true, all_linked.frozen?) end def test_load_country_info info = @data_source.load_country_info('GB') assert_equal('GB', info.code) end def test_load_country_info_not_exist assert_raises(InvalidCountryCode) do @data_source.load_country_info('ZZ') end end def test_load_country_info_invalid assert_raises(InvalidCountryCode) do @data_source.load_country_info('../Countries/GB') end end def test_load_country_info_nil assert_raises(InvalidCountryCode) do @data_source.load_country_info(nil) end end def test_load_country_info_case assert_raises(InvalidCountryCode) do @data_source.load_country_info('gb') end end def test_load_country_info_tainted safe_test do code = 'NL'.taint assert(code.tainted?) info = @data_source.load_country_info(code) assert_equal('NL', info.code) assert(code.tainted?) end end def test_load_country_info_tainted_and_frozen safe_test do info = @data_source.load_country_info('NL'.taint.freeze) assert_equal('NL', info.code) end end def test_country_codes codes = @data_source.country_codes assert_equal(TZInfo::Data::Indexes::Countries.countries.keys, codes) assert_equal(true, codes.frozen?) end end tzinfo-1.2.2/test/tc_country_timezone.rb0000644000004100000410000001405112400401360020453 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCCountryTimezone < Minitest::Test def test_identifier_new! ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) assert_equal('Europe/London', ct.identifier) end def test_identifier_new ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_equal('Europe/London', ct.identifier) end def test_latitude_new! ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) assert_equal(Rational(2059, 40), ct.latitude) end def test_latitude_new ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_equal(Rational(2059, 40), ct.latitude) end def test_longitude_new! ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) assert_equal(Rational(-5, 16), ct.longitude) end def test_longitude_new ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_equal(Rational(-5, 16), ct.longitude) end def test_description_omit_new! ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) assert_nil(ct.description) end def test_description_omit_new ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_nil(ct.description) end def test_description_nil_new! ct = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, nil) assert_nil(ct.description) end def test_description_nil_new ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16), nil) assert_nil(ct.description) end def test_description_new! ct = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time') assert_equal('Eastern Time', ct.description) end def test_description_new ct = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time') assert_equal('Eastern Time', ct.description) end def test_timezone ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_kind_of(TimezoneProxy, ct.timezone) assert_equal('Europe/London', ct.timezone.identifier) end def test_description_or_friendly_idenfier_no_description ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_equal('London', ct.description_or_friendly_identifier) end def test_description_or_friendly_idenfier_description ct = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time') assert_equal('Eastern Time', ct.description_or_friendly_identifier) end def test_equality_1 ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) ct2 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) ct3 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) ct4 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, 'Description') ct5 = CountryTimezone.new!('Europe/LondonB', 2059, 40, -5, 16) ct6 = CountryTimezone.new!('Europe/London', 2060, 40, -5, 16) ct7 = CountryTimezone.new!('Europe/London', 2059, 40, -6, 16) assert_equal(true, ct1 == ct1) assert_equal(true, ct1 == ct2) assert_equal(true, ct1 == ct3) assert_equal(false, ct1 == ct4) assert_equal(false, ct1 == ct5) assert_equal(false, ct1 == ct6) assert_equal(false, ct1 == ct7) end def test_equality_2 ct1 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time') ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2') assert_equal(true, ct1 == ct1) assert_equal(false, ct1 == ct2) end def test_equality_non_country_timezone ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_equal(false, ct == Object.new) end def test_eql_1 ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) ct2 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) ct3 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) ct4 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16, 'Description') ct5 = CountryTimezone.new!('Europe/LondonB', 2059, 40, -5, 16) ct6 = CountryTimezone.new!('Europe/London', 2060, 40, -5, 16) ct7 = CountryTimezone.new!('Europe/London', 2059, 40, -6, 16) assert_equal(true, ct1.eql?(ct1)) assert_equal(true, ct1.eql?(ct2)) assert_equal(true, ct1.eql?(ct3)) assert_equal(false, ct1.eql?(ct4)) assert_equal(false, ct1.eql?(ct5)) assert_equal(false, ct1.eql?(ct6)) assert_equal(false, ct1.eql?(ct7)) end def test_eql_2 ct1 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time') ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time2') assert_equal(true, ct1.eql?(ct1)) assert_equal(false, ct1.eql?(ct2)) end def test_eql_non_country_timezone ct = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) assert_equal(false, ct.eql?(Object.new)) end def test_hash_new! ct1 = CountryTimezone.new!('Europe/London', 2059, 40, -5, 16) ct2 = CountryTimezone.new!('America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time') assert_equal('Europe/London'.hash ^ 2059.hash ^ 40.hash ^ -5.hash ^ 16.hash ^ nil.hash, ct1.hash) assert_equal('America/New_York'.hash ^ 48857.hash ^ 1200.hash ^ -266423.hash ^ 3600.hash ^ 'Eastern Time'.hash, ct2.hash) end def test_hash_new ct1 = CountryTimezone.new('Europe/London', Rational(2059, 40), Rational(-5, 16)) ct2 = CountryTimezone.new('America/New_York', Rational(48857, 1200), Rational(-266423, 3600), 'Eastern Time') assert_equal('Europe/London'.hash ^ 2059.hash ^ 40.hash ^ -5.hash ^ 16.hash ^ nil.hash, ct1.hash) assert_equal('America/New_York'.hash ^ 48857.hash ^ 1200.hash ^ -266423.hash ^ 3600.hash ^ 'Eastern Time'.hash, ct2.hash) end end tzinfo-1.2.2/test/tc_linked_timezone_info.rb0000644000004100000410000000121012400401360021222 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCLinkedTimezoneInfo < Minitest::Test def test_identifier lti = LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked') assert_equal('Test/Zone', lti.identifier) end def test_link_to_identifier lti = LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked') assert_equal('Test/Linked', lti.link_to_identifier) end def test_construct_timezone lti = LinkedTimezoneInfo.new('Test/Zone', 'Europe/London') tz = lti.create_timezone assert_kind_of(LinkedTimezone, tz) assert_equal('Test/Zone', tz.identifier) end end tzinfo-1.2.2/test/ts_all.rb0000644000004100000410000000042712400401360015630 0ustar www-datawww-data# Force a particular timezone to be local (helps find issues when local # timezone isn't GMT). This won't work on Windows. ENV['TZ'] = 'America/Los_Angeles' Dir[File.join(File.expand_path(File.dirname(__FILE__)), 'tc_*.rb')].each {|t| require t} puts "Using #{DataSource.get}" tzinfo-1.2.2/test/tc_data_source.rb0000644000004100000410000001366612400401360017342 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') require 'tmpdir' include TZInfo class TCDataSource < Minitest::Test class InitDataSource < DataSource end class DummyDataSource < DataSource end def setup @orig_data_source = DataSource.get DataSource.set(InitDataSource.new) @orig_search_path = ZoneinfoDataSource.search_path.clone end def teardown DataSource.set(@orig_data_source) ZoneinfoDataSource.search_path = @orig_search_path end def test_get data_source = DataSource.get assert_kind_of(InitDataSource, data_source) end def test_get_default_ruby_only code = <<-EOF require 'tmpdir' begin Dir.mktmpdir('tzinfo_test_dir') do |dir| TZInfo::ZoneinfoDataSource.search_path = [dir] puts TZInfo::DataSource.get.class end rescue Exception => e puts "Unexpected exception: \#{e}" end EOF assert_sub_process_returns(['TZInfo::RubyDataSource'], code, [TZINFO_TEST_DATA_DIR]) end def test_get_default_zoneinfo_only code = <<-EOF require 'tmpdir' begin Dir.mktmpdir('tzinfo_test_dir') do |dir| TZInfo::ZoneinfoDataSource.search_path = [dir, '#{TZINFO_TEST_ZONEINFO_DIR}'] puts TZInfo::DataSource.get.class puts TZInfo::DataSource.get.zoneinfo_dir end rescue Exception => e puts "Unexpected exception: \#{e}" end EOF assert_sub_process_returns( ['TZInfo::ZoneinfoDataSource', TZINFO_TEST_ZONEINFO_DIR], code) end def test_get_default_ruby_and_zoneinfo code = <<-EOF begin TZInfo::ZoneinfoDataSource.search_path = ['#{TZINFO_TEST_ZONEINFO_DIR}'] puts TZInfo::DataSource.get.class rescue Exception => e puts "Unexpected exception: \#{e}" end EOF assert_sub_process_returns(['TZInfo::RubyDataSource'], code, [TZINFO_TEST_DATA_DIR]) end def test_get_default_no_data code = <<-EOF require 'tmpdir' begin Dir.mktmpdir('tzinfo_test_dir') do |dir| TZInfo::ZoneinfoDataSource.search_path = [dir] begin data_source = TZInfo::DataSource.get puts "No exception raised, returned \#{data_source} instead" rescue Exception => e puts e.class end end rescue Exception => e puts "Unexpected exception: \#{e}" end EOF assert_sub_process_returns(['TZInfo::DataSourceNotFound'], code) end def test_set_instance DataSource.set(DummyDataSource.new) data_source = DataSource.get assert_kind_of(DummyDataSource, data_source) end def test_set_standard_ruby DataSource.set(:ruby) data_source = DataSource.get assert_kind_of(RubyDataSource, data_source) end def test_set_standard_zoneinfo_search Dir.mktmpdir('tzinfo_test_dir') do |dir| FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.touch(File.join(dir, 'zone.tab')) ZoneinfoDataSource.search_path = [dir] DataSource.set(:zoneinfo) data_source = DataSource.get assert_kind_of(ZoneinfoDataSource, data_source) assert_equal(dir, data_source.zoneinfo_dir) end end def test_set_standard_zoneinfo_search_zone1970 Dir.mktmpdir('tzinfo_test_dir') do |dir| FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.touch(File.join(dir, 'zone1970.tab')) ZoneinfoDataSource.search_path = [dir] DataSource.set(:zoneinfo) data_source = DataSource.get assert_kind_of(ZoneinfoDataSource, data_source) assert_equal(dir, data_source.zoneinfo_dir) end end def test_set_standard_zoneinfo_explicit Dir.mktmpdir('tzinfo_test_dir') do |dir| FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.touch(File.join(dir, 'zone.tab')) DataSource.set(:zoneinfo, dir) data_source = DataSource.get assert_kind_of(ZoneinfoDataSource, data_source) assert_equal(dir, data_source.zoneinfo_dir) end end def test_set_standard_zoneinfo_explicit_zone1970 Dir.mktmpdir('tzinfo_test_dir') do |dir| FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.touch(File.join(dir, 'zone.tab')) DataSource.set(:zoneinfo, dir) data_source = DataSource.get assert_kind_of(ZoneinfoDataSource, data_source) assert_equal(dir, data_source.zoneinfo_dir) end end def test_set_standard_zoneinfo_explicit_alternate_iso3166 Dir.mktmpdir('tzinfo_test_dir') do |dir| zoneinfo_dir = File.join(dir, 'zoneinfo') tab_dir = File.join(dir, 'tab') FileUtils.mkdir(zoneinfo_dir) FileUtils.mkdir(tab_dir) FileUtils.touch(File.join(zoneinfo_dir, 'zone.tab')) iso3166_file = File.join(tab_dir, 'iso3166.tab') FileUtils.touch(iso3166_file) DataSource.set(:zoneinfo, zoneinfo_dir, iso3166_file) data_source = DataSource.get assert_kind_of(ZoneinfoDataSource, data_source) assert_equal(zoneinfo_dir, data_source.zoneinfo_dir) end end def test_set_standard_zoneinfo_search_not_found Dir.mktmpdir('tzinfo_test_dir') do |dir| ZoneinfoDataSource.search_path = [dir] assert_raises(ZoneinfoDirectoryNotFound) do DataSource.set(:zoneinfo) end assert_kind_of(InitDataSource, DataSource.get) end end def test_set_standard_zoneinfo_explicit_invalid Dir.mktmpdir('tzinfo_test_dir') do |dir| assert_raises(InvalidZoneinfoDirectory) do DataSource.set(:zoneinfo, dir) end assert_kind_of(InitDataSource, DataSource.get) end end def test_set_standard_zoneinfo_wrong_arg_count assert_raises(ArgumentError) do DataSource.set(:zoneinfo, 1, 2, 3) end assert_kind_of(InitDataSource, DataSource.get) end end tzinfo-1.2.2/test/tc_ruby_core_support.rb0000644000004100000410000001430012400401360020620 0ustar www-datawww-data# encoding: UTF-8 require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCRubyCoreSupport < Minitest::Test def test_rational_new! assert_equal(Rational(3,4), RubyCoreSupport.rational_new!(3,4)) end def test_datetime_new! assert_equal(DateTime.new(2008,10,5,12,0,0, 0, Date::ITALY), RubyCoreSupport.datetime_new!(2454745,0,2299161)) assert_equal(DateTime.new(2008,10,5,13,0,0, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new!(2454745,Rational(1, 24),2299161)) assert_equal(DateTime.new(2008,10,5,20,30,0, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(117827777, 48), 0, 2299161)) assert_equal(DateTime.new(2008,10,5,21,30,0, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new!(Rational(117827777, 48), Rational(1, 24), 2299161)) assert_equal(DateTime.new(2008,10,6,6,26,21, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(70696678127,28800), 0, 2299161)) assert_equal(DateTime.new(2008,10,6,7,26,21, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new!(Rational(70696678127, 28800), Rational(1, 24), 2299161)) assert_equal(DateTime.new(-4712,1,1,12,0,0, 0, Date::ITALY), RubyCoreSupport.datetime_new!(0, 0, 2299161)) assert_equal(DateTime.new(-4712,1,1,13,0,0, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new!(0, Rational(1, 24), 2299161)) assert_equal(DateTime.new(-4713,12,31,23,58,59, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-43261, 86400), 0, 2299161)) assert_equal(DateTime.new(-4712,1,1,0,58,59, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-43261, 86400), Rational(1, 24), 2299161)) assert_equal(DateTime.new(-4713,12,30,23,58,59, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-129661, 86400), 0, 2299161)) assert_equal(DateTime.new(-4713,12,31,0,58,59, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-129661, 86400), Rational(1, 24), 2299161)) end def test_datetime_new assert_equal(DateTime.new(2012, 12, 31, 23, 59, 59, 0, Date::ITALY), RubyCoreSupport.datetime_new(2012, 12, 31, 23, 59, 59, 0, Date::ITALY)) assert_equal(DateTime.new(2013, 2, 6, 23, 2, 36, Rational(1, 24), Date::ITALY), RubyCoreSupport.datetime_new(2013, 2, 6, 23, 2, 36, Rational(1,24), Date::ITALY)) assert_equal(DateTime.new(2012, 12, 31, 23, 59, 59, 0, Date::ITALY) + Rational(1, 86400000), RubyCoreSupport.datetime_new(2012, 12, 31, 23, 59, 59 + Rational(1, 1000), 0, Date::ITALY)) assert_equal(DateTime.new(2001, 10, 12, 12, 22, 59, Rational(1, 24), Date::ITALY) + Rational(501, 86400000), RubyCoreSupport.datetime_new(2001, 10, 12, 12, 22, 59 + Rational(501, 1000), Rational(1, 24), Date::ITALY)) end def test_time_supports_negative if RubyCoreSupport.time_supports_negative assert_equal(Time.utc(1969, 12, 31, 23, 59, 59), Time.at(-1).utc) else assert_raises(ArgumentError) do Time.at(-1) end end end def test_time_supports_64_bit if RubyCoreSupport.time_supports_64bit assert_equal(Time.utc(1901, 12, 13, 20, 45, 51), Time.at(-2147483649).utc) assert_equal(Time.utc(2038, 1, 19, 3, 14, 8), Time.at(2147483648).utc) else assert_raises(RangeError) do Time.at(-2147483649) end assert_raises(RangeError) do Time.at(2147483648) end end end def test_time_nsec t = Time.utc(2013, 2, 6, 21, 56, 23, 567890 + Rational(123,1000)) if t.respond_to?(:nsec) assert_equal(567890123, RubyCoreSupport.time_nsec(t)) else assert_equal(567890000, RubyCoreSupport.time_nsec(t)) end end def test_force_encoding s = [0xC2, 0xA9].pack('c2') if s.respond_to?(:force_encoding) # Ruby 1.9+ - should call String#force_encoding assert_equal('ASCII-8BIT', s.encoding.name) assert_equal(2, s.bytesize) result = RubyCoreSupport.force_encoding(s, 'UTF-8') assert_same(s, result) assert_equal('UTF-8', s.encoding.name) assert_equal(2, s.bytesize) assert_equal(1, s.length) assert_equal('©', s) else # Ruby 1.8 - no-op result = RubyCoreSupport.force_encoding(s, 'UTF-8') assert_same(s, result) assert_equal('©', s) end end begin SUPPORTS_ENCODING = !!Encoding rescue NameError SUPPORTS_ENCODING = false end def check_open_file_test_file_bytes(test_file) if SUPPORTS_ENCODING File.open(test_file, 'r') do |file| file.binmode data = file.read(2) refute_nil(data) assert_equal(2, data.length) bytes = data.unpack('C2') assert_equal(0xC2, bytes[0]) assert_equal(0xA9, bytes[1]) end end end def check_open_file_test_file_content(file) content = file.gets refute_nil(content) content.chomp! if SUPPORTS_ENCODING assert_equal('UTF-8', content.encoding.name) assert_equal(1, content.length) assert_equal(2, content.bytesize) assert_equal('©', content) else assert_equal('x', content) end end def test_open_file Dir.mktmpdir('tzinfo_test') do |dir| test_file = File.join(dir, 'test.txt') file = RubyCoreSupport.open_file(test_file, 'w', :external_encoding => 'UTF-8') begin file.puts(SUPPORTS_ENCODING ? '©' : 'x') ensure file.close end check_open_file_test_file_bytes(test_file) file = RubyCoreSupport.open_file(test_file, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') begin check_open_file_test_file_content(file) ensure file.close end end end def test_open_file_block Dir.mktmpdir('tzinfo_test') do |dir| test_file = File.join(dir, 'test.txt') RubyCoreSupport.open_file(test_file, 'w', :external_encoding => 'UTF-8') do |file| file.puts(SUPPORTS_ENCODING ? '©' : 'x') end check_open_file_test_file_bytes(test_file) RubyCoreSupport.open_file(test_file, 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file| check_open_file_test_file_content(file) end end end end tzinfo-1.2.2/test/tc_timezone_definition.rb0000644000004100000410000000675212400401360021111 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneDefinition < Minitest::Test module DataTest include TimezoneDefinition timezone 'Test/Data/Zone' do |tz| tz.offset :o0, -75, 0, :LMT tz.offset :o1, 0, 0, :GMT tz.transition 1847, 12, :o1, 2760187969, 1152 end end module LinkedTest include TimezoneDefinition linked_timezone 'Test/Linked/Zone', 'Test/Linked_To/Zone' end module DoubleDataTest include TimezoneDefinition timezone 'Test/Data/Zone1' do |tz| tz.offset :o0, -75, 0, :LMT tz.offset :o1, 0, 0, :GMT tz.transition 1847, 12, :o1, 2760187969, 1152 end timezone 'Test/Data/Zone2' do |tz| tz.offset :o0, 75, 0, :LMT tz.offset :o1, 0, 0, :GMT tz.transition 1847, 12, :o1, 2760187969, 1152 end end module DoubleLinkedTest include TimezoneDefinition linked_timezone 'Test/Linked/Zone1', 'Test/Linked_To/Zone1' linked_timezone 'Test/Linked/Zone2', 'Test/Linked_To/Zone2' end module DataLinkedTest include TimezoneDefinition timezone 'Test/Data/Zone1' do |tz| tz.offset :o0, -75, 0, :LMT tz.offset :o1, 0, 0, :GMT tz.transition 1847, 12, :o1, 2760187969, 1152 end linked_timezone 'Test/Linked/Zone2', 'Test/Linked_To/Zone2' end module LinkedDataTest include TimezoneDefinition linked_timezone 'Test/Linked/Zone1', 'Test/Linked_To/Zone1' timezone 'Test/Data/Zone2' do |tz| tz.offset :o0, -75, 0, :LMT tz.offset :o1, 0, 0, :GMT tz.transition 1847, 12, :o1, 2760187969, 1152 end end def test_data assert_kind_of(TransitionDataTimezoneInfo, DataTest.get) assert_equal('Test/Data/Zone', DataTest.get.identifier) assert_equal(:LMT, DataTest.get.period_for_utc(DateTime.new(1847,12,1,0,1,14)).abbreviation) assert_equal(:GMT, DataTest.get.period_for_utc(DateTime.new(1847,12,1,0,1,15)).abbreviation) end def test_linked assert_kind_of(LinkedTimezoneInfo, LinkedTest.get) assert_equal('Test/Linked/Zone', LinkedTest.get.identifier) assert_equal('Test/Linked_To/Zone', LinkedTest.get.link_to_identifier) end def test_double_data assert_kind_of(TransitionDataTimezoneInfo, DoubleDataTest.get) assert_equal('Test/Data/Zone2', DoubleDataTest.get.identifier) assert_equal(:LMT, DoubleDataTest.get.period_for_utc(DateTime.new(1847,12,1,0,1,14)).abbreviation) assert_equal(:GMT, DoubleDataTest.get.period_for_utc(DateTime.new(1847,12,1,0,1,15)).abbreviation) end def test_double_linked assert_kind_of(LinkedTimezoneInfo, DoubleLinkedTest.get) assert_equal('Test/Linked/Zone2', DoubleLinkedTest.get.identifier) assert_equal('Test/Linked_To/Zone2', DoubleLinkedTest.get.link_to_identifier) end def test_data_linked assert_kind_of(LinkedTimezoneInfo, DataLinkedTest.get) assert_equal('Test/Linked/Zone2', DataLinkedTest.get.identifier) assert_equal('Test/Linked_To/Zone2', DataLinkedTest.get.link_to_identifier) end def test_linked_data assert_kind_of(TransitionDataTimezoneInfo, LinkedDataTest.get) assert_equal('Test/Data/Zone2', LinkedDataTest.get.identifier) assert_equal(:LMT, LinkedDataTest.get.period_for_utc(DateTime.new(1847,12,1,0,1,14)).abbreviation) assert_equal(:GMT, LinkedDataTest.get.period_for_utc(DateTime.new(1847,12,1,0,1,15)).abbreviation) end end tzinfo-1.2.2/test/tc_timezone_utc.rb0000644000004100000410000000253512400401360017547 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneUTC < Minitest::Test def test_2004 tz = Timezone.get('UTC') assert_equal(DateTime.new(2004,1,1,0,0,0), tz.utc_to_local(DateTime.new(2004,1,1,0,0,0))) assert_equal(DateTime.new(2004,12,31,23,59,59), tz.utc_to_local(DateTime.new(2004,12,31,23,59,59))) assert_equal(DateTime.new(2004,1,1,0,0,0), tz.local_to_utc(DateTime.new(2004,1,1,0,0,0))) assert_equal(DateTime.new(2004,12,31,23,59,59), tz.local_to_utc(DateTime.new(2004,12,31,23,59,59))) assert_equal(:UTC, tz.period_for_utc(DateTime.new(2004,1,1,0,0,0)).zone_identifier) assert_equal(:UTC, tz.period_for_utc(DateTime.new(2004,12,31,23,59,59)).zone_identifier) assert_equal(:UTC, tz.period_for_local(DateTime.new(2004,1,1,0,0,0)).zone_identifier) assert_equal(:UTC, tz.period_for_local(DateTime.new(2004,12,31,23,59,59)).zone_identifier) assert_equal(0, tz.period_for_utc(DateTime.new(2004,1,1,0,0,0)).utc_total_offset) assert_equal(0, tz.period_for_utc(DateTime.new(2004,12,31,23,59,59)).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(2004,1,1,0,0,0)).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(2004,12,31,23,59,59)).utc_total_offset) end end tzinfo-1.2.2/test/tc_zoneinfo_country_info.rb0000644000004100000410000000432512400401360021466 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCZoneinfoCountryInfo < Minitest::Test def test_code ci = ZoneinfoCountryInfo.new('ZZ', 'Zzz', []) {|c| } assert_equal('ZZ', ci.code) end def test_name ci = ZoneinfoCountryInfo.new('ZZ', 'Zzz', []) {|c| } assert_equal('Zzz', ci.name) end def test_zone_identifiers_empty ci = ZoneinfoCountryInfo.new('ZZ', 'Zzz', []) {|c| } assert(ci.zone_identifiers.empty?) assert(ci.zone_identifiers.frozen?) end def test_zone_identifiers zones = [ CountryTimezone.new('ZZ/TimezoneB', Rational(1, 2), Rational(1, 2), 'Timezone B'), CountryTimezone.new('ZZ/TimezoneA', Rational(1, 4), Rational(1, 4), 'Timezone A'), CountryTimezone.new('ZZ/TimezoneC', Rational(-10, 3), Rational(-20, 7), 'C'), CountryTimezone.new('ZZ/TimezoneD', Rational(-10, 3), Rational(-20, 7)) ] ci = ZoneinfoCountryInfo.new('ZZ', 'Zzz', zones) assert_equal(['ZZ/TimezoneB', 'ZZ/TimezoneA', 'ZZ/TimezoneC', 'ZZ/TimezoneD'], ci.zone_identifiers) assert(ci.zone_identifiers.frozen?) assert(!ci.zones.equal?(zones)) assert(!zones.frozen?) end def test_zones_empty ci = ZoneinfoCountryInfo.new('ZZ', 'Zzz', []) assert(ci.zones.empty?) assert(ci.zones.frozen?) end def test_zones zones = [ CountryTimezone.new('ZZ/TimezoneB', Rational(1, 2), Rational(1, 2), 'Timezone B'), CountryTimezone.new('ZZ/TimezoneA', Rational(1, 4), Rational(1, 4), 'Timezone A'), CountryTimezone.new('ZZ/TimezoneC', Rational(-10, 3), Rational(-20, 7), 'C'), CountryTimezone.new('ZZ/TimezoneD', Rational(-10, 3), Rational(-20, 7)) ] ci = ZoneinfoCountryInfo.new('ZZ', 'Zzz', zones) assert_equal([CountryTimezone.new('ZZ/TimezoneB', Rational(1, 2), Rational(1, 2), 'Timezone B'), CountryTimezone.new('ZZ/TimezoneA', Rational(1, 4), Rational(1, 4), 'Timezone A'), CountryTimezone.new('ZZ/TimezoneC', Rational(-10, 3), Rational(-20, 7), 'C'), CountryTimezone.new('ZZ/TimezoneD', Rational(-10, 3), Rational(-20, 7))], ci.zones) assert(ci.zones.frozen?) assert(!ci.zones.equal?(zones)) assert(!zones.frozen?) end end tzinfo-1.2.2/test/tc_country_info.rb0000644000004100000410000000052112400401360017551 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCCountryInfo < Minitest::Test def test_code ci = CountryInfo.new('ZZ', 'Zzz') {|c| } assert_equal('ZZ', ci.code) end def test_name ci = CountryInfo.new('ZZ', 'Zzz') {|c| } assert_equal('Zzz', ci.name) end end tzinfo-1.2.2/test/tc_timezone_transition_definition.rb0000644000004100000410000003046212400401360023356 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') require 'date' include TZInfo class TCTimezoneTransitionDefinition < Minitest::Test def test_initialize_timestamp_only assert_nothing_raised do TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) end end def test_initialize_timestamp_and_datetime assert_nothing_raised do TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) end end def test_initialize_datetime_only assert_nothing_raised do TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) end end def test_at t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) assert(TimeOrDateTime.new(1148949080).eql?(t1.at)) assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 0, 31, 20)).eql?(t2.at)) assert(TimeOrDateTime.new(1148949080).eql?(t3.at)) end def test_at_before_negative_32_bit t = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800) if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit assert(TimeOrDateTime.new(-2147483649).eql?(t.at)) else assert(TimeOrDateTime.new(DateTime.new(1901, 12, 13, 20, 45, 51)).eql?(t.at)) end end def test_at_before_epoch t = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400) if RubyCoreSupport.time_supports_negative assert(TimeOrDateTime.new(-1).eql?(t.at)) else assert(TimeOrDateTime.new(DateTime.new(1969, 12, 31, 23, 59, 59)).eql?(t.at)) end end def test_at_after_32bit t = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350) if RubyCoreSupport.time_supports_64bit assert(TimeOrDateTime.new(2147483648).eql?(t.at)) else assert(TimeOrDateTime.new(DateTime.new(2038, 1, 19, 3, 14, 8)).eql?(t.at)) end end def test_eql_timestamp t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949081) t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3601, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t7 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3601, 0, :TST), 1148949080) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) assert_equal(false, t1.eql?(t3)) assert_equal(true, t1.eql?(t4)) assert_equal(false, t1.eql?(t5)) assert_equal(false, t1.eql?(t6)) assert_equal(false, t1.eql?(t7)) assert_equal(false, t1.eql?(Object.new)) end def test_eql_datetime t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 7852433803, 3200) t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3601, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t7 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3601, 0, :TST), 5300392727, 2160) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) assert_equal(false, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(false, t1.eql?(t5)) assert_equal(false, t1.eql?(t6)) assert_equal(false, t1.eql?(t7)) assert_equal(false, t1.eql?(Object.new)) end def test_eql_timestamp_and_datetime t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148952681, 7852433803, 3200) t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3601, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) t7 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3601, 0, :TST), 1148949080, 5300392727, 2160) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) assert_equal(true, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(false, t1.eql?(t5)) assert_equal(false, t1.eql?(t6)) assert_equal(false, t1.eql?(t7)) assert_equal(false, t1.eql?(Object.new)) end def test_eql_timestamp_and_datetime_before_negative_32bit t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -2147483649) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 69573092117, 28800) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit assert_equal(true, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(true, t3.eql?(t1)) assert_equal(false, t4.eql?(t1)) else assert_equal(false, t1.eql?(t3)) assert_equal(true, t1.eql?(t4)) assert_equal(false, t3.eql?(t1)) assert_equal(true, t4.eql?(t1)) end end def test_eql_timestamp_and_datetime_before_epoch t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -1) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 210866759999, 86400) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) if RubyCoreSupport.time_supports_negative assert_equal(true, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(true, t3.eql?(t1)) assert_equal(false, t4.eql?(t1)) else assert_equal(false, t1.eql?(t3)) assert_equal(true, t1.eql?(t4)) assert_equal(false, t3.eql?(t1)) assert_equal(true, t4.eql?(t1)) end end def test_eql_timestamp_and_datetime_after_32bit t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147483648) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 3328347557, 1350) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) if RubyCoreSupport.time_supports_64bit assert_equal(true, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(true, t3.eql?(t1)) assert_equal(false, t4.eql?(t1)) else assert_equal(false, t1.eql?(t3)) assert_equal(true, t1.eql?(t4)) assert_equal(false, t3.eql?(t1)) assert_equal(true, t4.eql?(t1)) end end def test_hash t1 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 5300392727, 2160) t3 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080, 5300392727, 2160) t4 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -2147483649, 69573092117, 28800) t5 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), -1, 210866759999, 86400) t6 = TimezoneTransitionDefinition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147483648, 3328347557, 1350) assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 1148949080.hash ^ nil.hash, t1.hash) assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 5300392727.hash ^ 2160.hash, t2.hash) assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 1148949080.hash ^ nil.hash, t3.hash) if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ -2147483649.hash ^ nil.hash, t4.hash) else assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 69573092117.hash ^ 28800.hash, t4.hash) end if RubyCoreSupport.time_supports_negative assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ -1.hash ^ nil.hash, t5.hash) else assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 210866759999.hash ^ 86400.hash, t5.hash) end if RubyCoreSupport.time_supports_64bit assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 2147483648.hash ^ nil.hash, t6.hash) else assert_equal(TimezoneOffset.new(3600, 3600, :TDT).hash ^ TimezoneOffset.new(3600, 0, :TST).hash ^ 3328347557.hash ^ 1350.hash, t6.hash) end end end tzinfo-1.2.2/test/tc_timezone_info.rb0000644000004100000410000000037012400401360017702 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneInfo < Minitest::Test def test_identifier ti = TimezoneInfo.new('Test/Zone') assert_equal('Test/Zone', ti.identifier) end end tzinfo-1.2.2/test/tc_timezone_transition.rb0000644000004100000410000003705512400401360021153 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') require 'date' include TZInfo class TCTimezoneTransition < Minitest::Test class TestTimezoneTransition < TimezoneTransition def initialize(offset, previous_offset, at) super(offset, previous_offset) @at = TimeOrDateTime.wrap(at) end def at @at end end def test_offset t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) assert_equal(TimezoneOffset.new(3600, 3600, :TDT), t.offset) end def test_previous_offset t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) assert_equal(TimezoneOffset.new(3600, 0, :TST), t.previous_offset) end def test_datetime t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), t1.datetime) assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), t2.datetime) assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), t3.datetime) end def test_time t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), t1.time) assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), t2.time) assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), t3.time) end def test_local_end_at t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert(TimeOrDateTime.new(1148952680).eql?(t1.local_end_at)) assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 1, 31, 20)).eql?(t2.local_end_at)) assert(TimeOrDateTime.new(Time.utc(2006, 5, 30, 1, 31, 20)).eql?(t3.local_end_at)) end def test_local_end t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert_equal(DateTime.new(2006, 5, 30, 1, 31, 20), t1.local_end) assert_equal(DateTime.new(2006, 5, 30, 1, 31, 20), t2.local_end) assert_equal(DateTime.new(2006, 5, 30, 1, 31, 20), t3.local_end) end def test_local_end_time t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert_equal(Time.utc(2006, 5, 30, 1, 31, 20), t1.local_end_time) assert_equal(Time.utc(2006, 5, 30, 1, 31, 20), t2.local_end_time) assert_equal(Time.utc(2006, 5, 30, 1, 31, 20), t3.local_end_time) end def test_local_start_at t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert(TimeOrDateTime.new(1148956280).eql?(t1.local_start_at)) assert(TimeOrDateTime.new(DateTime.new(2006, 5, 30, 2, 31, 20)).eql?(t2.local_start_at)) assert(TimeOrDateTime.new(Time.utc(2006, 5, 30, 2, 31, 20)).eql?(t3.local_start_at)) end def test_local_start t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert_equal(DateTime.new(2006, 5, 30, 2, 31, 20), t1.local_start) assert_equal(DateTime.new(2006, 5, 30, 2, 31, 20), t2.local_start) assert_equal(DateTime.new(2006, 5, 30, 2, 31, 20), t3.local_start) end def test_local_start_time t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) assert_equal(Time.utc(2006, 5, 30, 2, 31, 20), t1.local_start_time) assert_equal(Time.utc(2006, 5, 30, 2, 31, 20), t2.local_start_time) assert_equal(Time.utc(2006, 5, 30, 2, 31, 20), t3.local_start_time) end if RubyCoreSupport.time_supports_negative def test_local_end_at_before_negative_32bit t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT), TimezoneOffset.new(-7200, 0, :TST), -2147482800) if RubyCoreSupport.time_supports_64bit assert(TimeOrDateTime.new(-2147490000).eql?(t.local_end_at)) else assert(TimeOrDateTime.new(DateTime.new(1901, 12, 13, 19, 0, 0)).eql?(t.local_end_at)) end end def test_local_start_at_before_negative_32bit t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT), TimezoneOffset.new(-7200, 0, :TST), -2147482800) if RubyCoreSupport.time_supports_64bit assert(TimeOrDateTime.new(-2147486400).eql?(t.local_start_at)) else assert(TimeOrDateTime.new(DateTime.new(1901, 12, 13, 20, 0, 0)).eql?(t.local_start_at)) end end end def test_local_end_at_before_epoch t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT), TimezoneOffset.new(-7200, 0, :TST), 1800) if RubyCoreSupport.time_supports_negative assert(TimeOrDateTime.new(-5400).eql?(t.local_end_at)) else assert(TimeOrDateTime.new(DateTime.new(1969, 12, 31, 22, 30, 0)).eql?(t.local_end_at)) end end def test_local_start_at_before_epoch t = TestTimezoneTransition.new(TimezoneOffset.new(-7200, 3600, :TDT), TimezoneOffset.new(-7200, 0, :TST), 1800) if RubyCoreSupport.time_supports_negative assert(TimeOrDateTime.new(-1800).eql?(t.local_start_at)) else assert(TimeOrDateTime.new(DateTime.new(1969, 12, 31, 23, 30, 0)).eql?(t.local_start_at)) end end def test_local_end_at_after_32bit t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147482800) if RubyCoreSupport.time_supports_64bit assert(TimeOrDateTime.new(2147486400).eql?(t.local_end_at)) else assert(TimeOrDateTime.new(DateTime.new(2038, 1, 19, 4, 0, 0)).eql?(t.local_end_at)) end end def test_local_start_at_after_32bit t = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 2147482800) if RubyCoreSupport.time_supports_64bit assert(TimeOrDateTime.new(2147490000).eql?(t.local_start_at)) else assert(TimeOrDateTime.new(DateTime.new(2038, 1, 19, 5, 0, 0)).eql?(t.local_start_at)) end end def test_equality_timestamp t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t4 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) t5 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949081) t6 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 1, 31, 21)) t7 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 1, 31, 21)) t8 = TestTimezoneTransition.new(TimezoneOffset.new(3601, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t9 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3601, 0, :TST), 1148949080) assert_equal(true, t1 == t1) assert_equal(true, t1 == t2) assert_equal(true, t1 == t3) assert_equal(true, t1 == t4) assert_equal(false, t1 == t5) assert_equal(false, t1 == t6) assert_equal(false, t1 == t7) assert_equal(false, t1 == t8) assert_equal(false, t1 == t9) assert_equal(false, t1 == Object.new) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) assert_equal(false, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(false, t1.eql?(t5)) assert_equal(false, t1.eql?(t6)) assert_equal(false, t1.eql?(t7)) assert_equal(false, t1.eql?(t8)) assert_equal(false, t1.eql?(t9)) assert_equal(false, t1.eql?(Object.new)) end def test_equality_datetime t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t4 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) t5 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 1, 31, 21)) t6 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949081) t7 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 1, 31, 21)) t8 = TestTimezoneTransition.new(TimezoneOffset.new(3601, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t9 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3601, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) assert_equal(true, t1 == t1) assert_equal(true, t1 == t2) assert_equal(true, t1 == t3) assert_equal(true, t1 == t4) assert_equal(false, t1 == t5) assert_equal(false, t1 == t6) assert_equal(false, t1 == t7) assert_equal(false, t1 == t8) assert_equal(false, t1 == t9) assert_equal(false, t1 == Object.new) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) assert_equal(false, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(false, t1.eql?(t5)) assert_equal(false, t1.eql?(t6)) assert_equal(false, t1.eql?(t7)) assert_equal(false, t1.eql?(t8)) assert_equal(false, t1.eql?(t9)) assert_equal(false, t1.eql?(Object.new)) end def test_equality_time t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 0, 31, 20)) t4 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t5 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), Time.utc(2006, 5, 30, 0, 31, 21)) t6 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), DateTime.new(2006, 5, 30, 1, 31, 21)) t7 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949081) t8 = TestTimezoneTransition.new(TimezoneOffset.new(3601, 3600, :TDT), TimezoneOffset.new(3600, 0, :TST), 1148949080) t9 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDT), TimezoneOffset.new(3601, 0, :TST), 1148949080) assert_equal(true, t1 == t1) assert_equal(true, t1 == t2) assert_equal(true, t1 == t3) assert_equal(true, t1 == t4) assert_equal(false, t1 == t5) assert_equal(false, t1 == t6) assert_equal(false, t1 == t7) assert_equal(false, t1 == t8) assert_equal(false, t1 == t9) assert_equal(false, t1 == Object.new) assert_equal(true, t1.eql?(t1)) assert_equal(true, t1.eql?(t2)) assert_equal(false, t1.eql?(t3)) assert_equal(false, t1.eql?(t4)) assert_equal(false, t1.eql?(t5)) assert_equal(false, t1.eql?(t6)) assert_equal(false, t1.eql?(t7)) assert_equal(false, t1.eql?(t8)) assert_equal(false, t1.eql?(t9)) assert_equal(false, t1.eql?(Object.new)) end def test_hash t1 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDTA), TimezoneOffset.new(3600, 0, :TSTA), 1148949080) t2 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDTB), TimezoneOffset.new(3600, 0, :TSTB), DateTime.new(2006, 5, 30, 1, 31, 20)) t3 = TestTimezoneTransition.new(TimezoneOffset.new(3600, 3600, :TDTC), TimezoneOffset.new(3600, 0, :TSTC), Time.utc(2006, 5, 30, 1, 31, 20)) assert_equal(TimezoneOffset.new(3600, 3600, :TDTA).hash ^ TimezoneOffset.new(3600, 0, :TSTA).hash ^ TimeOrDateTime.new(1148949080).hash, t1.hash) assert_equal(TimezoneOffset.new(3600, 3600, :TDTB).hash ^ TimezoneOffset.new(3600, 0, :TSTB).hash ^ TimeOrDateTime.new(DateTime.new(2006, 5, 30, 1, 31, 20)).hash, t2.hash) assert_equal(TimezoneOffset.new(3600, 3600, :TDTC).hash ^ TimezoneOffset.new(3600, 0, :TSTC).hash ^ TimeOrDateTime.new(Time.utc(2006, 5, 30, 1, 31, 20)).hash, t3.hash) end end tzinfo-1.2.2/test/tc_country.rb0000644000004100000410000001267212400401360016550 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCCountry < Minitest::Test def setup @orig_data_source = DataSource.get Country.send :init_countries end def teardown DataSource.set(@orig_data_source) end def test_get_valid c = Country.get('GB') assert c assert_equal('GB', c.code) end def test_get_not_exist assert_raises(InvalidCountryCode) { Country.get('ZZ') } end def test_get_invalid assert_raises(InvalidCountryCode) { Country.get('../Countries/GB') } end def test_get_nil assert_raises(InvalidCountryCode) { Country.get(nil) } end def test_get_case assert_raises(InvalidCountryCode) { Country.get('gb') } end def test_get_tainted_loaded Country.get('GB') safe_test do code = 'GB'.taint assert(code.tainted?) country = Country.get(code) assert_equal('GB', country.code) assert(code.tainted?) end end def test_get_tainted_and_frozen_loaded Country.get('GB') safe_test do country = Country.get('GB'.taint.freeze) assert_equal('GB', country.code) end end def test_get_tainted_not_previously_loaded safe_test do code = 'GB'.taint assert(code.tainted?) country = Country.get(code) assert_equal('GB', country.code) assert(code.tainted?) end end def test_get_tainted_and_frozen_not_previously_loaded safe_test do country = Country.get('GB'.taint.freeze) assert_equal('GB', country.code) end end def test_new_nil assert_raises(InvalidCountryCode) { Country.new(nil) } end def test_new_arg c = Country.new('GB') assert_same(Country.get('GB'), c) end def test_new_arg_not_exist assert_raises(InvalidCountryCode) { Country.new('ZZ') } end def test_all_codes all_codes = Country.all_codes assert_kind_of(Array, all_codes) end def test_all all = Country.all assert_equal(Country.all_codes, all.collect {|c| c.code}) end def test_code assert_equal('US', Country.get('US').code) end def test_name assert_kind_of(String, Country.get('US').name) end def test_to_s assert_equal(Country.get('US').name, Country.get('US').to_s) assert_equal(Country.get('GB').name, Country.get('GB').to_s) end def test_zone_identifiers zone_names = Country.get('US').zone_names assert_kind_of(Array, zone_names) assert_equal(true, zone_names.frozen?) end def test_zone_names assert_equal(Country.get('US').zone_identifiers, Country.get('US').zone_names) end def test_zones zones = Country.get('US').zones assert_kind_of(Array, zones) assert_equal(Country.get('US').zone_identifiers, zones.collect {|z| z.identifier}) zones.each {|z| assert_kind_of(TimezoneProxy, z)} end def test_zone_info zones = Country.get('US').zone_info assert_kind_of(Array, zones) assert_equal(true, zones.frozen?) assert_equal(Country.get('US').zone_identifiers, zones.collect {|z| z.identifier}) assert_equal(Country.get('US').zone_identifiers, zones.collect {|z| z.timezone.identifier}) zones.each {|z| assert_kind_of(CountryTimezone, z)} end def test_compare assert_equal(0, Country.get('GB') <=> Country.get('GB')) assert_equal(-1, Country.get('GB') <=> Country.get('US')) assert_equal(1, Country.get('US') <=> Country.get('GB')) assert_equal(-1, Country.get('FR') <=> Country.get('US')) assert_equal(1, Country.get('US') <=> Country.get('FR')) end def test_compare_non_comparable assert_nil(Country.get('GB') <=> Object.new) end def test_equality assert_equal(true, Country.get('GB') == Country.get('GB')) assert_equal(false, Country.get('GB') == Country.get('US')) assert(!(Country.get('GB') == Object.new)) end def test_eql assert_equal(true, Country.get('GB').eql?(Country.get('GB'))) assert_equal(false, Country.get('GB').eql?(Country.get('US'))) assert(!Country.get('GB').eql?(Object.new)) end def test_hash assert_equal('GB'.hash, Country.get('GB').hash) assert_equal('US'.hash, Country.get('US').hash) end def test_marshal c = Country.get('US') # Should get back the same instance because load calls Country.get. assert_same(c, Marshal.load(Marshal.dump(c))) end def test_reload # If country gets reloaded for some reason, it needs to force a reload of # the country index. c = Country.get('US') assert_equal('US', Country.get('US').code) # Suppress redefined method warnings. without_warnings do load 'tzinfo/country.rb' end c = Country.get('US') assert_equal('US', Country.get('US').code) end def test_get_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Country.get('GB') end end def test_new_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Country.new('GB') end end def test_all_codes_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Country.all_codes end end def test_all_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Country.all end end end tzinfo-1.2.2/test/tc_timezone.rb0000644000004100000410000015261712400401360016703 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezone < Minitest::Test class BlockCalled < StandardError end class TestTimezone < Timezone def self.new(identifier, period_for_utc = nil, periods_for_local = nil, expected = nil) t = super() t.send(:setup, identifier, period_for_utc, periods_for_local, expected) t end def identifier @identifier end def period_for_utc(utc) utc = TimeOrDateTime.wrap(utc) raise "Unexpected utc #{utc} in period_for_utc" unless @expected.eql?(utc) @period_for_utc end def periods_for_local(local) local = TimeOrDateTime.wrap(local) raise "Unexpected local #{local} in periods_for_local" unless @expected.eql?(local) @periods_for_local.clone end def transitions_up_to(utc_to, utc_from = nil) raise 'transitions_up_to called' end private def setup(identifier, period_for_utc, periods_for_local, expected) @identifier = identifier @period_for_utc = period_for_utc @periods_for_local = periods_for_local || [] @expected = TimeOrDateTime.wrap(expected) end end class OffsetsUpToTestTimezone < Timezone def self.new(identifier, expected_utc_to, expected_utc_from, transitions_up_to) t = super() t.send(:setup, identifier, expected_utc_to, expected_utc_from, transitions_up_to) t end def identifier @identifier end def period_for_utc(utc) raise 'period_for_utc called' end def periods_for_local(local) raise 'periods_for_local called' end def transitions_up_to(utc_to, utc_from = nil) utc_to = TimeOrDateTime.wrap(utc_to) raise "Unexpected utc_to #{utc_to || 'nil'} in transitions_up_to" unless @expected_utc_to.eql?(utc_to) utc_from = utc_from ? TimeOrDateTime.wrap(utc_from) : nil raise "Unexpected utc_from #{utc_from || 'nil'} in transitions_up_to" unless @expected_utc_from.eql?(utc_from) if utc_from && utc_to <= utc_from raise ArgumentError, 'utc_to must be greater than utc_from' end @transitions_up_to end private def setup(identifier, expected_utc_to, expected_utc_from, transitions_up_to) @identifier = identifier @expected_utc_to = TimeOrDateTime.wrap(expected_utc_to) @expected_utc_from = expected_utc_from ? TimeOrDateTime.wrap(expected_utc_from) : nil @transitions_up_to = transitions_up_to end end class OffsetsUpToNoTransitionsTestTimezone < Timezone def self.new(identifier, expected_utc_to, expected_utc_from, period_for_utc) t = super() t.send(:setup, identifier, expected_utc_to, expected_utc_from, period_for_utc) t end def identifier @identifier end def period_for_utc(utc) utc = TimeOrDateTime.wrap(utc) raise "Unexpected utc #{utc} in period_for_utc (should be utc_from)" if @expected_utc_from && !@expected_utc_from.eql?(utc) raise "Unexpected utc #{utc} in period_for_utc (should be < utc_to)" if !@expected_utc_from && @expected_utc_to <= utc @period_for_utc end def periods_for_local(local) raise 'periods_for_local called' end def transitions_up_to(utc_to, utc_from = nil) utc_to = TimeOrDateTime.wrap(utc_to) raise "Unexpected utc_to #{utc_to || 'nil'} in transitions_up_to" unless @expected_utc_to.eql?(utc_to) utc_from = utc_from ? TimeOrDateTime.wrap(utc_from) : nil raise "Unexpected utc_from #{utc_from || 'nil'} in transitions_up_to" unless @expected_utc_from.eql?(utc_from) if utc_from && utc_to <= utc_from raise ArgumentError, 'utc_to must be greater than utc_from' end [] end private def setup(identifier, expected_utc_to, expected_utc_from, period_for_utc) @identifier = identifier @expected_utc_to = TimeOrDateTime.wrap(expected_utc_to) @expected_utc_from = expected_utc_from ? TimeOrDateTime.wrap(expected_utc_from) : nil @period_for_utc = period_for_utc end end class TestTimezoneTransition < TimezoneTransition def initialize(offset, previous_offset, at) super(offset, previous_offset) @at = TimeOrDateTime.wrap(at) end def at @at end end def setup @orig_default_dst = Timezone.default_dst @orig_data_source = DataSource.get Timezone.send :init_loaded_zones end def teardown Timezone.default_dst = @orig_default_dst DataSource.set(@orig_data_source) end def test_default_dst_initial_value assert_nil(Timezone.default_dst) end def test_set_default_dst Timezone.default_dst = true assert_equal(true, Timezone.default_dst) Timezone.default_dst = false assert_equal(false, Timezone.default_dst) Timezone.default_dst = nil assert_nil(Timezone.default_dst) Timezone.default_dst = 0 assert_equal(true, Timezone.default_dst) end def test_get_valid_1 tz = Timezone.get('Europe/London') assert_kind_of(DataTimezone, tz) assert_equal('Europe/London', tz.identifier) end def test_get_valid_2 tz = Timezone.get('UTC') # ZoneinfoDataSource doesn't return LinkedTimezoneInfo for any timezone. if DataSource.get.load_timezone_info('UTC').kind_of?(LinkedTimezoneInfo) assert_kind_of(LinkedTimezone, tz) else assert_kind_of(DataTimezone, tz) end assert_equal('UTC', tz.identifier) end def test_get_valid_3 tz = Timezone.get('America/Argentina/Buenos_Aires') assert_kind_of(DataTimezone, tz) assert_equal('America/Argentina/Buenos_Aires', tz.identifier) end def test_get_same_instance tz1 = Timezone.get('Europe/London') tz2 = Timezone.get('Europe/London') assert_same(tz1, tz2) end def test_get_not_exist assert_raises(InvalidTimezoneIdentifier) { Timezone.get('Nowhere/Special') } end def test_get_invalid assert_raises(InvalidTimezoneIdentifier) { Timezone.get('../Definitions/UTC') } end def test_get_nil assert_raises(InvalidTimezoneIdentifier) { Timezone.get(nil) } end def test_get_case Timezone.get('Europe/Prague') assert_raises(InvalidTimezoneIdentifier) { Timezone.get('Europe/prague') } end def test_get_proxy_valid proxy = Timezone.get_proxy('Europe/London') assert_kind_of(TimezoneProxy, proxy) assert_equal('Europe/London', proxy.identifier) end def test_get_proxy_not_exist proxy = Timezone.get_proxy('Not/There') assert_kind_of(TimezoneProxy, proxy) assert_equal('Not/There', proxy.identifier) end def test_get_proxy_invalid proxy = Timezone.get_proxy('../Invalid/Identifier') assert_kind_of(TimezoneProxy, proxy) assert_equal('../Invalid/Identifier', proxy.identifier) end def test_get_tainted_loaded Timezone.get('Europe/Andorra') safe_test do identifier = 'Europe/Andorra'.taint assert(identifier.tainted?) tz = Timezone.get(identifier) assert_equal('Europe/Andorra', tz.identifier) assert(identifier.tainted?) end end def test_get_tainted_and_frozen_loaded Timezone.get('Europe/Andorra') safe_test do tz = Timezone.get('Europe/Andorra'.taint.freeze) assert_equal('Europe/Andorra', tz.identifier) end end def test_get_tainted_not_previously_loaded safe_test do identifier = 'Europe/Andorra'.taint assert(identifier.tainted?) tz = Timezone.get(identifier) assert_equal('Europe/Andorra', tz.identifier) assert(identifier.tainted?) end end def test_get_tainted_and_frozen_not_previously_loaded safe_test do tz = Timezone.get('Europe/Amsterdam'.taint.freeze) assert_equal('Europe/Amsterdam', tz.identifier) end end def test_new_no_args tz = Timezone.new assert_raises(UnknownTimezone) { tz.identifier } assert_raises(UnknownTimezone) { tz.friendly_identifier } assert_raises(UnknownTimezone) { tz.utc_to_local(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.local_to_utc(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.period_for_utc(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.periods_for_local(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.period_for_local(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.now } assert_raises(UnknownTimezone) { tz.current_period_and_time } assert_raises(UnknownTimezone) { tz.transitions_up_to(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.canonical_identifier } assert_raises(UnknownTimezone) { tz.canonical_zone } end def test_new_nil tz = Timezone.new(nil) assert_raises(UnknownTimezone) { tz.identifier } assert_raises(UnknownTimezone) { tz.friendly_identifier } assert_raises(UnknownTimezone) { tz.utc_to_local(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.local_to_utc(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.period_for_utc(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.periods_for_local(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.period_for_local(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.now } assert_raises(UnknownTimezone) { tz.current_period_and_time } assert_raises(UnknownTimezone) { tz.transitions_up_to(DateTime.new(2006,1,1,1,0,0)) } assert_raises(UnknownTimezone) { tz.canonical_identifier } assert_raises(UnknownTimezone) { tz.canonical_zone } end def test_new_arg tz = Timezone.new('Europe/London') assert_same(Timezone.get('Europe/London'), tz) end def test_new_arg_not_exist assert_raises(InvalidTimezoneIdentifier) { Timezone.new('Nowhere/Special') } end def test_all all = Timezone.all expected = DataSource.get.timezone_identifiers.collect {|identifier| Timezone.get_proxy(identifier)} assert_equal(expected, all) end def test_all_identifiers all = Timezone.all_identifiers assert_equal(DataSource.get.timezone_identifiers, all) end def test_all_data_zones all_data = Timezone.all_data_zones expected = DataSource.get.data_timezone_identifiers.collect {|identifier| Timezone.get_proxy(identifier)} assert_equal(expected, all_data) end def test_all_data_zone_identifiers all_data = Timezone.all_data_zone_identifiers assert_equal(DataSource.get.data_timezone_identifiers, all_data) end def test_all_linked_zones all_linked = Timezone.all_linked_zones expected = DataSource.get.linked_timezone_identifiers.collect {|identifier| Timezone.get_proxy(identifier)} assert_equal(expected, all_linked) end def test_all_linked_zone_identifiers all_linked = Timezone.all_linked_zone_identifiers assert_equal(DataSource.get.linked_timezone_identifiers, all_linked) end def test_all_country_zones # Probably should relax this test - just need all the zones, don't care # about order. expected = Country.all.inject([]) {|result,country| result += country.zones } expected.uniq! all_country_zones = Timezone.all_country_zones assert_equal(expected, all_country_zones) all_country_zone_identifiers = Timezone.all_country_zone_identifiers assert_equal(all_country_zone_identifiers.length, all_country_zones.length) all_country_zones.each {|zone| assert_kind_of(TimezoneProxy, zone) assert(all_country_zone_identifiers.include?(zone.identifier)) } end def test_all_country_zone_identifiers # Probably should relax this test - just need all the zones, don't care # about order. expected = Country.all.inject([]) {|result,country| result += country.zone_identifiers } expected.uniq! assert_equal(expected, Timezone.all_country_zone_identifiers) end def test_us_zones # Probably should relax this test - just need all the zones, don't care # about order. us_zones = Timezone.us_zones assert_equal(Country.get('US').zones.uniq, us_zones) us_zone_identifiers = Timezone.us_zone_identifiers assert_equal(us_zone_identifiers.length, us_zones.length) us_zones.each {|zone| assert_kind_of(TimezoneProxy, zone) assert(us_zone_identifiers.include?(zone.identifier)) } end def test_us_zone_identifiers # Probably should relax this test - just need all the zones, don't care # about order. assert_equal(Country.get('US').zone_identifiers.uniq, Timezone.us_zone_identifiers) end def test_identifier assert_raises(UnknownTimezone) { Timezone.new.identifier } assert_equal('Europe/Paris', TestTimezone.new('Europe/Paris').identifier) end def test_name assert_raises(UnknownTimezone) { Timezone.new.name } assert_equal('Europe/Paris', TestTimezone.new('Europe/Paris').name) end def test_friendly_identifier assert_equal('Paris', TestTimezone.new('Europe/Paris').friendly_identifier(true)) assert_equal('Europe - Paris', TestTimezone.new('Europe/Paris').friendly_identifier(false)) assert_equal('Europe - Paris', TestTimezone.new('Europe/Paris').friendly_identifier) assert_equal('Knox, Indiana', TestTimezone.new('America/Indiana/Knox').friendly_identifier(true)) assert_equal('America - Knox, Indiana', TestTimezone.new('America/Indiana/Knox').friendly_identifier(false)) assert_equal('America - Knox, Indiana', TestTimezone.new('America/Indiana/Knox').friendly_identifier) assert_equal('Dumont D\'Urville', TestTimezone.new('Antarctica/DumontDUrville').friendly_identifier(true)) assert_equal('Antarctica - Dumont D\'Urville', TestTimezone.new('Antarctica/DumontDUrville').friendly_identifier(false)) assert_equal('Antarctica - Dumont D\'Urville', TestTimezone.new('Antarctica/DumontDUrville').friendly_identifier) assert_equal('McMurdo', TestTimezone.new('Antarctica/McMurdo').friendly_identifier(true)) assert_equal('Antarctica - McMurdo', TestTimezone.new('Antarctica/McMurdo').friendly_identifier(false)) assert_equal('Antarctica - McMurdo', TestTimezone.new('Antarctica/McMurdo').friendly_identifier) assert_equal('GMT+1', TestTimezone.new('Etc/GMT+1').friendly_identifier(true)) assert_equal('Etc - GMT+1', TestTimezone.new('Etc/GMT+1').friendly_identifier(false)) assert_equal('Etc - GMT+1', TestTimezone.new('Etc/GMT+1').friendly_identifier) assert_equal('UTC', TestTimezone.new('UTC').friendly_identifier(true)) assert_equal('UTC', TestTimezone.new('UTC').friendly_identifier(false)) assert_equal('UTC', TestTimezone.new('UTC').friendly_identifier) end def test_to_s assert_equal('Europe - Paris', TestTimezone.new('Europe/Paris').to_s) assert_equal('America - Knox, Indiana', TestTimezone.new('America/Indiana/Knox').to_s) assert_equal('Antarctica - Dumont D\'Urville', TestTimezone.new('Antarctica/DumontDUrville').to_s) assert_equal('Antarctica - McMurdo', TestTimezone.new('Antarctica/McMurdo').to_s) assert_equal('Etc - GMT+1', TestTimezone.new('Etc/GMT+1').to_s) assert_equal('UTC', TestTimezone.new('UTC').to_s) end def test_period_for_local dt = DateTime.new(2005,2,18,16,24,23) dt2 = DateTime.new(2005,2,18,16,24,23).new_offset(Rational(5,24)) dt3 = DateTime.new(2005,2,18,16,24,23 + Rational(789, 1000)) t = Time.utc(2005,2,18,16,24,23) t2 = Time.local(2005,2,18,16,24,23) t3 = Time.utc(2005,2,18,16,24,23,789000) ts = t.to_i o1 = TimezoneOffset.new(0, 0, :GMT) o2 = TimezoneOffset.new(0, 3600, :BST) period = TimezonePeriod.new( TestTimezoneTransition.new(o1, o2, 1099184400), TestTimezoneTransition.new(o2, o1, 1111885200)) dt_period = TestTimezone.new('Europe/London', nil, [period], dt).period_for_local(dt) dt2_period = TestTimezone.new('Europe/London', nil, [period], dt2).period_for_local(dt2) dt3_period = TestTimezone.new('Europe/London', nil, [period], dt3).period_for_local(dt3) t_period = TestTimezone.new('Europe/London', nil, [period], t).period_for_local(t) t2_period = TestTimezone.new('Europe/London', nil, [period], t2).period_for_local(t2) t3_period = TestTimezone.new('Europe/London', nil, [period], t3).period_for_local(t3) ts_period = TestTimezone.new('Europe/London', nil, [period], ts).period_for_local(ts) assert_equal(period, dt_period) assert_equal(period, dt2_period) assert_equal(period, dt3_period) assert_equal(period, t_period) assert_equal(period, t2_period) assert_equal(period, t3_period) assert_equal(period, ts_period) end def test_period_for_local_invalid dt = DateTime.new(2004,4,4,2,30,0) tz = TestTimezone.new('America/New_York', nil, [], dt) assert_raises(PeriodNotFound) do tz.period_for_local(dt) end end def test_period_for_local_ambiguous o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,0,0) dt2 = DateTime.new(2004,10,31,1,0,Rational(555,1000)) t = Time.utc(2004,10,31,1,30,0) t2 = Time.utc(2004,10,31,1,30,0,555000) i = Time.utc(2004,10,31,1,59,59).to_i dt_tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) dt2_tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt2) t_tz = TestTimezone.new('America/New_York', nil, [p1, p2], t) t2_tz = TestTimezone.new('America/New_York', nil, [p1, p2], t2) i_tz = TestTimezone.new('America/New_York', nil, [p1, p2], i) assert_raises(AmbiguousTime) { dt_tz.period_for_local(dt) } assert_raises(AmbiguousTime) { dt2_tz.period_for_local(dt2) } assert_raises(AmbiguousTime) { t_tz.period_for_local(t) } assert_raises(AmbiguousTime) { t2_tz.period_for_local(t2) } assert_raises(AmbiguousTime) { i_tz.period_for_local(i) } end def test_period_for_local_not_found dt = DateTime.new(2004,4,4,2,0,0) dt2 = DateTime.new(2004,4,4,2,0,Rational(987,1000)) t = Time.utc(2004,4,4,2,30,0) t2 = Time.utc(2004,4,4,2,30,0,987000) i = Time.utc(2004,4,4,2,59,59).to_i dt_tz = TestTimezone.new('America/New_York', nil, [], dt) dt2_tz = TestTimezone.new('America/New_York', nil, [], dt2) t_tz = TestTimezone.new('America/New_York', nil, [], t) t2_tz = TestTimezone.new('America/New_York', nil, [], t2) i_tz = TestTimezone.new('America/New_York', nil, [], i) assert_raises(PeriodNotFound) { dt_tz.period_for_local(dt) } assert_raises(PeriodNotFound) { dt2_tz.period_for_local(dt2) } assert_raises(PeriodNotFound) { t_tz.period_for_local(t) } assert_raises(PeriodNotFound) { t2_tz.period_for_local(t2) } assert_raises(PeriodNotFound) { i_tz.period_for_local(i) } end def test_period_for_local_default_dst_set_true Timezone.default_dst = true o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_equal(p1, tz.period_for_local(dt)) assert_equal(p1, tz.period_for_local(dt, true)) assert_equal(p2, tz.period_for_local(dt, false)) assert_raises(AmbiguousTime) { tz.period_for_local(dt, nil) } end def test_period_for_local_default_dst_set_false Timezone.default_dst = false o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_equal(p2, tz.period_for_local(dt)) assert_equal(p1, tz.period_for_local(dt, true)) assert_equal(p2, tz.period_for_local(dt, false)) assert_raises(AmbiguousTime) { tz.period_for_local(dt, nil) } end def test_period_for_local_dst_flag_resolved o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_equal(p1, tz.period_for_local(dt, true)) assert_equal(p2, tz.period_for_local(dt, false)) assert_equal(p1, tz.period_for_local(dt, true) {|periods| raise BlockCalled, 'should not be called' }) assert_equal(p2, tz.period_for_local(dt, false) {|periods| raise BlockCalled, 'should not be called' }) end def test_period_for_local_dst_block_called o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_raises(BlockCalled) { tz.period_for_local(dt) {|periods| assert_equal([p1, p2], periods) # raise exception to test that the block was called raise BlockCalled, 'should be raised' } } assert_equal(p1, tz.period_for_local(dt) {|periods| periods.first}) assert_equal(p2, tz.period_for_local(dt) {|periods| periods.last}) assert_equal(p1, tz.period_for_local(dt) {|periods| [periods.first]}) assert_equal(p2, tz.period_for_local(dt) {|periods| [periods.last]}) end def test_period_for_local_dst_cannot_resolve # At midnight local time on Aug 5 1915 in Warsaw, the clocks were put back # 24 minutes and both periods were non-DST. Hence the block should be # called regardless of the value of the Boolean dst parameter. o0 = TimezoneOffset.new(5040, 0, :LMT) o1 = TimezoneOffset.new(5040, 0, :WMT) o2 = TimezoneOffset.new(3600, 0, :CET) o3 = TimezoneOffset.new(3600, 3600, :CEST) t1 = TestTimezoneTransition.new(o1, o0, DateTime.new(1879, 12, 31, 22, 36, 0)) t2 = TestTimezoneTransition.new(o2, o1, DateTime.new(1915, 8, 4, 22, 36, 0)) t3 = TestTimezoneTransition.new(o3, o2, DateTime.new(1916, 4, 30, 22, 0, 0)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(1915,8,4,23,40,0) tz = TestTimezone.new('Europe/Warsaw', nil, [p1, p2], dt) assert_raises(BlockCalled) { tz.period_for_local(dt, true) {|periods| assert_equal([p1, p2], periods) raise BlockCalled, 'should be raised' } } assert_raises(BlockCalled) { tz.period_for_local(dt, false) {|periods| assert_equal([p1, p2], periods) raise BlockCalled, 'should be raised' } } end def test_period_for_local_block_ambiguous o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_raises(AmbiguousTime) do tz.period_for_local(dt) {|periods| nil} end assert_raises(AmbiguousTime) do tz.period_for_local(dt) {|periods| periods} end assert_raises(AmbiguousTime) do tz.period_for_local(dt) {|periods| []} end assert_raises(AmbiguousTime) do tz.period_for_local(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'} end end def test_utc_to_local dt = DateTime.new(2005,6,18,16,24,23) dt2 = DateTime.new(2005,6,18,16,24,23).new_offset(Rational(5,24)) dtu = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)) dtu2 = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)).new_offset(Rational(5,24)) t = Time.utc(2005,6,18,16,24,23) t2 = Time.local(2005,6,18,16,24,23) tu = Time.utc(2005,6,18,16,24,23,567000) tu2 = Time.local(2005,6,18,16,24,23,567000) ts = t.to_i o1 = TimezoneOffset.new(0, 0, :GMT) o2 = TimezoneOffset.new(0, 3600, :BST) period = TimezonePeriod.new( TestTimezoneTransition.new(o2, o1, 1111885200), TestTimezoneTransition.new(o1, o2, 1130634000)) assert_equal(DateTime.new(2005,6,18,17,24,23), TestTimezone.new('Europe/London', period, [], dt).utc_to_local(dt)) assert_equal(DateTime.new(2005,6,18,17,24,23), TestTimezone.new('Europe/London', period, [], dt2).utc_to_local(dt2)) assert_equal(DateTime.new(2005,6,18,17,24,23 + Rational(567,1000)), TestTimezone.new('Europe/London', period, [], dtu).utc_to_local(dtu)) assert_equal(DateTime.new(2005,6,18,17,24,23 + Rational(567,1000)), TestTimezone.new('Europe/London', period, [], dtu2).utc_to_local(dtu2)) assert_equal(Time.utc(2005,6,18,17,24,23), TestTimezone.new('Europe/London', period, [], t).utc_to_local(t)) assert_equal(Time.utc(2005,6,18,17,24,23), TestTimezone.new('Europe/London', period, [], t2).utc_to_local(t2)) assert_equal(Time.utc(2005,6,18,17,24,23,567000), TestTimezone.new('Europe/London', period, [], tu).utc_to_local(tu)) assert_equal(Time.utc(2005,6,18,17,24,23,567000), TestTimezone.new('Europe/London', period, [], tu2).utc_to_local(tu2)) assert_equal(Time.utc(2005,6,18,17,24,23).to_i, TestTimezone.new('Europe/London', period, [], ts).utc_to_local(ts)) end def test_utc_to_local_offset dt = DateTime.new(2005,6,18,16,24,23) dt2 = DateTime.new(2005,6,18,16,24,23).new_offset(Rational(5,24)) dtu = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)) dtu2 = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)).new_offset(Rational(5,24)) t = Time.utc(2005,6,18,16,24,23) t2 = Time.local(2005,6,18,16,24,23) tu = Time.utc(2005,6,18,16,24,23,567000) tu2 = Time.local(2005,6,18,16,24,23,567000) o1 = TimezoneOffset.new(0, 0, :GMT) o2 = TimezoneOffset.new(0, 3600, :BST) period = TimezonePeriod.new( TestTimezoneTransition.new(o2, o1, 1111885200), TestTimezoneTransition.new(o1, o2, 1130634000)) assert_equal(0, TestTimezone.new('Europe/London', period, [], dt).utc_to_local(dt).offset) assert_equal(0, TestTimezone.new('Europe/London', period, [], dt2).utc_to_local(dt2).offset) assert_equal(0, TestTimezone.new('Europe/London', period, [], dtu).utc_to_local(dtu).offset) assert_equal(0, TestTimezone.new('Europe/London', period, [], dtu2).utc_to_local(dtu2).offset) assert_equal(0, TestTimezone.new('Europe/London', period, [], t).utc_to_local(t).utc_offset) assert(TestTimezone.new('Europe/London', period, [], t).utc_to_local(t).utc?) assert_equal(0, TestTimezone.new('Europe/London', period, [], t2).utc_to_local(t2).utc_offset) assert(TestTimezone.new('Europe/London', period, [], t2).utc_to_local(t2).utc?) assert_equal(0, TestTimezone.new('Europe/London', period, [], tu).utc_to_local(tu).utc_offset) assert(TestTimezone.new('Europe/London', period, [], tu).utc_to_local(tu).utc?) assert_equal(0, TestTimezone.new('Europe/London', period, [], tu2).utc_to_local(tu2).utc_offset) assert(TestTimezone.new('Europe/London', period, [], tu2).utc_to_local(tu2).utc?) end def test_local_to_utc dt = DateTime.new(2005,6,18,16,24,23) dt2 = DateTime.new(2005,6,18,16,24,23).new_offset(Rational(5, 24)) dtu = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)) dtu2 = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)).new_offset(Rational(5, 24)) t = Time.utc(2005,6,18,16,24,23) t2 = Time.local(2005,6,18,16,24,23) tu = Time.utc(2005,6,18,16,24,23,567000) tu2 = Time.local(2005,6,18,16,24,23,567000) ts = t.to_i o1 = TimezoneOffset.new(0, 0, :GMT) o2 = TimezoneOffset.new(0, 3600, :BST) period = TimezonePeriod.new( TestTimezoneTransition.new(o2, o1, 1111885200), TestTimezoneTransition.new(o1, o2, 1130634000)) assert_equal(DateTime.new(2005,6,18,15,24,23), TestTimezone.new('Europe/London', nil, [period], dt).local_to_utc(dt)) assert_equal(DateTime.new(2005,6,18,15,24,23), TestTimezone.new('Europe/London', nil, [period], dt2).local_to_utc(dt2)) assert_equal(DateTime.new(2005,6,18,15,24,23 + Rational(567,1000)), TestTimezone.new('Europe/London', nil, [period], dtu).local_to_utc(dtu)) assert_equal(DateTime.new(2005,6,18,15,24,23 + Rational(567,1000)), TestTimezone.new('Europe/London', nil, [period], dtu2).local_to_utc(dtu2)) assert_equal(Time.utc(2005,6,18,15,24,23), TestTimezone.new('Europe/London', nil, [period], t).local_to_utc(t)) assert_equal(Time.utc(2005,6,18,15,24,23), TestTimezone.new('Europe/London', nil, [period], t2).local_to_utc(t2)) assert_equal(Time.utc(2005,6,18,15,24,23,567000), TestTimezone.new('Europe/London', nil, [period], tu).local_to_utc(tu)) assert_equal(Time.utc(2005,6,18,15,24,23,567000), TestTimezone.new('Europe/London', nil, [period], tu2).local_to_utc(tu2)) assert_equal(Time.utc(2005,6,18,15,24,23).to_i, TestTimezone.new('Europe/London', nil, [period], ts).local_to_utc(ts)) end def test_local_to_utc_offset dt = DateTime.new(2005,6,18,16,24,23) dt2 = DateTime.new(2005,6,18,16,24,23).new_offset(Rational(5, 24)) dtu = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)) dtu2 = DateTime.new(2005,6,18,16,24,23 + Rational(567,1000)).new_offset(Rational(5, 24)) t = Time.utc(2005,6,18,16,24,23) t2 = Time.local(2005,6,18,16,24,23) tu = Time.utc(2005,6,18,16,24,23,567000) tu2 = Time.local(2005,6,18,16,24,23,567000) o1 = TimezoneOffset.new(0, 0, :GMT) o2 = TimezoneOffset.new(0, 3600, :BST) period = TimezonePeriod.new( TestTimezoneTransition.new(o2, o1, 1111885200), TestTimezoneTransition.new(o1, o2, 1130634000)) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], dt).local_to_utc(dt).offset) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], dt2).local_to_utc(dt2).offset) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], dtu).local_to_utc(dtu).offset) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], dtu2).local_to_utc(dtu2).offset) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], t).local_to_utc(t).utc_offset) assert(TestTimezone.new('Europe/London', nil, [period], t).local_to_utc(t).utc?) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], t2).local_to_utc(t2).utc_offset) assert(TestTimezone.new('Europe/London', nil, [period], t2).local_to_utc(t2).utc?) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], tu).local_to_utc(tu).utc_offset) assert(TestTimezone.new('Europe/London', nil, [period], tu).local_to_utc(tu).utc?) assert_equal(0, TestTimezone.new('Europe/London', nil, [period], tu2).local_to_utc(tu2).utc_offset) assert(TestTimezone.new('Europe/London', nil, [period], tu2).local_to_utc(tu2).utc?) end def test_local_to_utc_utc_local_returns_utc # Check that UTC time instances are always returned even if the system # is using UTC as the time zone. # Note that this will only test will only work correctly on platforms where # setting the TZ environment variable has an effect. If setting TZ has no # effect, then this test will still pass. old_tz = ENV['TZ'] begin ENV['TZ'] = 'UTC' tz = Timezone.get('America/New_York') t = tz.local_to_utc(Time.local(2014, 1, 11, 17, 18, 41)) assert_equal(Time.utc(2014, 1, 11, 22, 18, 41), t) assert(t.utc?) ensure ENV['TZ'] = old_tz end end def test_local_to_utc_invalid dt = DateTime.new(2004,4,4,2,30,0) tz = TestTimezone.new('America/New_York', nil, [], dt) assert_raises(PeriodNotFound) { tz.local_to_utc(dt) } t = Time.utc(2004,4,4,2,30,0) tz = TestTimezone.new('America/New_York', nil, [], t) assert_raises(PeriodNotFound) { tz.local_to_utc(t) } i = Time.utc(2004,4,4,2,30,0).to_i tz = TestTimezone.new('America/New_York', nil, [], i) assert_raises(PeriodNotFound) { tz.local_to_utc(i) } end def test_local_to_utc_ambiguous o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_raises(AmbiguousTime) { tz.local_to_utc(dt) } t = Time.utc(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], t) assert_raises(AmbiguousTime) { tz.local_to_utc(t) } i = Time.utc(2004,10,31,1,30,0).to_i tz = TestTimezone.new('America/New_York', nil, [p1, p2], i) assert_raises(AmbiguousTime) { tz.local_to_utc(i) } f = Time.utc(2004,10,31,1,30,0,501).to_i tz = TestTimezone.new('America/New_York', nil, [p1, p2], f) assert_raises(AmbiguousTime) { tz.local_to_utc(f) } end def test_local_to_utc_not_found dt = DateTime.new(2004,4,4,2,0,0) t = Time.utc(2004,4,4,2,30,0) i = Time.utc(2004,4,4,2,59,59).to_i dt_tz = TestTimezone.new('America/New_York', nil, [], dt) t_tz = TestTimezone.new('America/New_York', nil, [], t) i_tz = TestTimezone.new('America/New_York', nil, [], i) assert_raises(PeriodNotFound) { dt_tz.local_to_utc(dt) } assert_raises(PeriodNotFound) { t_tz.local_to_utc(t) } assert_raises(PeriodNotFound) { i_tz.local_to_utc(i) } end def test_local_to_utc_default_dst_set_true Timezone.default_dst = true o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt)) assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true)) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false)) assert_raises(AmbiguousTime) { tz.local_to_utc(dt, nil) } assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt) {|periods| raise BlockCalled, 'should not be called' }) end def test_local_to_utc_default_dst_set_false Timezone.default_dst = false o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt)) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false)) assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true)) assert_raises(AmbiguousTime) { tz.local_to_utc(dt, nil) } assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt) {|periods| raise BlockCalled, 'should not be called' }) end def test_local_to_utc_dst_flag_resolved o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true)) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false)) assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt, true) {|periods| raise BlockCalled, 'should not be called' }) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt, false) {|periods| raise BlockCalled, 'should not be called' }) end def test_local_to_utc_dst_block_called o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_raises(BlockCalled) { tz.local_to_utc(dt) {|periods| assert_equal([p1, p2], periods) # raise exception to test that the block was called raise BlockCalled, 'should be raised' } } assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt) {|periods| periods.first}) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt) {|periods| periods.last}) assert_equal(DateTime.new(2004,10,31,5,30,0), tz.local_to_utc(dt) {|periods| [periods.first]}) assert_equal(DateTime.new(2004,10,31,6,30,0), tz.local_to_utc(dt) {|periods| [periods.last]}) end def test_local_to_utc_dst_cannot_resolve # At midnight local time on Aug 5 1915 in Warsaw, the clocks were put back # 24 minutes and both periods were non-DST. Hence the block should be # called regardless of the value of the Boolean dst parameter. o0 = TimezoneOffset.new(5040, 0, :LMT) o1 = TimezoneOffset.new(5040, 0, :WMT) o2 = TimezoneOffset.new(3600, 0, :CET) o3 = TimezoneOffset.new(3600, 3600, :CEST) t1 = TestTimezoneTransition.new(o1, o0, DateTime.new(1879, 12, 31, 22, 36, 0)) t2 = TestTimezoneTransition.new(o2, o1, DateTime.new(1915, 8, 4, 22, 36, 0)) t3 = TestTimezoneTransition.new(o3, o2, DateTime.new(1916, 4, 30, 22, 0, 0)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(1915,8,4,23,40,0) tz = TestTimezone.new('Europe/Warsaw', nil, [p1, p2], dt) assert_raises(BlockCalled) do tz.local_to_utc(dt, true) do |periods| assert_equal([p1, p2], periods) raise BlockCalled, 'should be raised' end end assert_raises(BlockCalled) do tz.local_to_utc(dt, false) do |periods| assert_equal([p1, p2], periods) raise BlockCalled, 'should be raised' end end assert_equal(DateTime.new(1915,8,4,22,16,0), tz.local_to_utc(dt) {|periods| periods.first}) assert_equal(DateTime.new(1915,8,4,22,40,0), tz.local_to_utc(dt) {|periods| periods.last}) assert_equal(DateTime.new(1915,8,4,22,16,0), tz.local_to_utc(dt) {|periods| [periods.first]}) assert_equal(DateTime.new(1915,8,4,22,40,0), tz.local_to_utc(dt) {|periods| [periods.last]}) end def test_local_to_utc_block_ambiguous o1 = TimezoneOffset.new(-18000, 0, :EST) o2 = TimezoneOffset.new(-18000, 3600, :EDT) t1 = TestTimezoneTransition.new(o2, o1, 1081062000) t2 = TestTimezoneTransition.new(o1, o2, 1099202400) t3 = TestTimezoneTransition.new(o2, o1, 1112511600) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t2, t3) dt = DateTime.new(2004,10,31,1,30,0) tz = TestTimezone.new('America/New_York', nil, [p1, p2], dt) assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| nil} } assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| periods} } assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| []} } assert_raises(AmbiguousTime) { tz.local_to_utc(dt) {|periods| raise AmbiguousTime, 'Ambiguous time'} } end def test_offsets_up_to o1 = TimezoneOffset.new(-17900, 0, :TESTLMT) o2 = TimezoneOffset.new(-18000, 3600, :TESTD) o3 = TimezoneOffset.new(-18000, 0, :TESTS) o4 = TimezoneOffset.new(-21600, 3600, :TESTD) o5 = TimezoneOffset.new(-21600, 0, :TESTS) t1 = TestTimezoneTransition.new(o2, o1, Time.utc(2010, 4,1,1,0,0).to_i) t2 = TestTimezoneTransition.new(o3, o2, Time.utc(2010,10,1,1,0,0).to_i) t3 = TestTimezoneTransition.new(o2, o3, Time.utc(2011, 3,1,1,0,0).to_i) t4 = TestTimezoneTransition.new(o4, o2, Time.utc(2011, 4,1,1,0,0).to_i) t5 = TestTimezoneTransition.new(o3, o4, Time.utc(2011,10,1,1,0,0).to_i) t6 = TestTimezoneTransition.new(o5, o3, Time.utc(2012, 3,1,1,0,0).to_i) assert_array_same_items([o1, o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,1), nil, [t1, t2, t3, t4, t5, t6]). offsets_up_to(Time.utc(2012,3,1,1,0,1))) assert_array_same_items([o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,1), Time.utc(2010,4,1,1,0,0), [t1, t2, t3, t4, t5, t6]). offsets_up_to(Time.utc(2012,3,1,1,0,1), Time.utc(2010,4,1,1,0,0))) assert_array_same_items([o1, o2, o3, o4], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,0), nil, [t1, t2, t3, t4, t5]). offsets_up_to(Time.utc(2012,3,1,1,0,0))) assert_array_same_items([o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,1), Time.utc(2010,4,1,1,0,1), [t2, t3, t4, t5, t6]). offsets_up_to(Time.utc(2012,3,1,1,0,1), Time.utc(2010,4,1,1,0,1))) assert_array_same_items([o2, o3], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2011,3,1,2,0,0), Time.utc(2011,3,1,0,0,0), [t3]). offsets_up_to(Time.utc(2011,3,1,2,0,0), Time.utc(2011,3,1,0,0,0))) assert_array_same_items([o3, o4], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,0), Time.utc(2011,4,1,1,0,0), [t4, t5]). offsets_up_to(Time.utc(2012,3,1,1,0,0), Time.utc(2011,4,1,1,0,0))) assert_array_same_items([o1, o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,1).to_i, nil, [t1, t2, t3, t4, t5, t6]). offsets_up_to(Time.utc(2012,3,1,1,0,1).to_i)) assert_array_same_items([o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,0).to_i, [t1, t2, t3, t4, t5, t6]). offsets_up_to(Time.utc(2012,3,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,0).to_i)) assert_array_same_items([o1, o2, o3, o4], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,0).to_i, nil, [t1, t2, t3, t4, t5]). offsets_up_to(Time.utc(2012,3,1,1,0,0).to_i)) assert_array_same_items([o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,1).to_i, [t2, t3, t4, t5, t6]). offsets_up_to(Time.utc(2012,3,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,1).to_i)) assert_array_same_items([o2, o3], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2011,3,1,2,0,0).to_i, Time.utc(2011,3,1,0,0,0).to_i, [t3]). offsets_up_to(Time.utc(2011,3,1,2,0,0).to_i, Time.utc(2011,3,1,0,0,0).to_i)) assert_array_same_items([o3, o4], OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,3,1,1,0,0).to_i, Time.utc(2011,4,1,1,0,0).to_i, [t4, t5]). offsets_up_to(Time.utc(2012,3,1,1,0,0).to_i, Time.utc(2011,4,1,1,0,0).to_i)) assert_array_same_items([o1, o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2012,3,1,1,0,1), nil, [t1, t2, t3, t4, t5, t6]). offsets_up_to(DateTime.new(2012,3,1,1,0,1))) assert_array_same_items([o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2012,3,1,1,0,1), DateTime.new(2010,4,1,1,0,0), [t1, t2, t3, t4, t5, t6]). offsets_up_to(DateTime.new(2012,3,1,1,0,1), DateTime.new(2010,4,1,1,0,0))) assert_array_same_items([o1, o2, o3, o4], OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2012,3,1,1,0,0), nil, [t1, t2, t3, t4, t5]). offsets_up_to(DateTime.new(2012,3,1,1,0,0))) assert_array_same_items([o2, o3, o4, o5], OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2012,3,1,1,0,1), DateTime.new(2010,4,1,1,0,1), [t2, t3, t4, t5, t6]). offsets_up_to(DateTime.new(2012,3,1,1,0,1), DateTime.new(2010,4,1,1,0,1))) assert_array_same_items([o2, o3], OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2011,3,1,2,0,0), DateTime.new(2011,3,1,0,0,0), [t3]). offsets_up_to(DateTime.new(2011,3,1,2,0,0), DateTime.new(2011,3,1,0,0,0))) assert_array_same_items([o3, o4], OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2012,3,1,1,0,0), DateTime.new(2011,4,1,1,0,0), [t4, t5]). offsets_up_to(DateTime.new(2012,3,1,1,0,0), DateTime.new(2011,4,1,1,0,0))) end def test_offsets_up_to_no_transitions o = TimezoneOffset.new(600, 0, :LMT) p = TimezonePeriod.new(nil, nil, o) assert_array_same_items([o], OffsetsUpToNoTransitionsTestTimezone.new('Test/Zone', Time.utc(2000,1,1,1,0,0), nil, p). offsets_up_to(Time.utc(2000,1,1,1,0,0))) assert_array_same_items([o], OffsetsUpToNoTransitionsTestTimezone.new('Test/Zone', Time.utc(2000,1,1,1,0,0), Time.utc(1990,1,1,1,0,0), p). offsets_up_to(Time.utc(2000,1,1,1,0,0), Time.utc(1990,1,1,1,0,0))) assert_array_same_items([o], OffsetsUpToNoTransitionsTestTimezone.new('Test/Zone', Time.utc(2000,1,1,1,0,0).to_i, nil, p). offsets_up_to(Time.utc(2000,1,1,1,0,0).to_i)) assert_array_same_items([o], OffsetsUpToNoTransitionsTestTimezone.new('Test/Zone', Time.utc(2000,1,1,1,0,0).to_i, Time.utc(1990,1,1,1,0,0).to_i, p). offsets_up_to(Time.utc(2000,1,1,1,0,0).to_i, Time.utc(1990,1,1,1,0,0).to_i)) assert_array_same_items([o], OffsetsUpToNoTransitionsTestTimezone.new('Test/Zone', DateTime.new(2000,1,1,1,0,0), nil, p). offsets_up_to(DateTime.new(2000,1,1,1,0,0))) assert_array_same_items([o], OffsetsUpToNoTransitionsTestTimezone.new('Test/Zone', DateTime.new(2000,1,1,1,0,0), DateTime.new(1990,1,1,1,0,0), p). offsets_up_to(DateTime.new(2000,1,1,1,0,0), DateTime.new(1990,1,1,1,0,0))) end def test_offsets_up_to_utc_to_not_greater_than_utc_from assert_raises(ArgumentError) do OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,8,1,0,0,0), Time.utc(2012,8,1,0,0,0), []). offsets_up_to(Time.utc(2012,8,1,0,0,0), Time.utc(2012,8,1,0,0,0)) end assert_raises(ArgumentError) do OffsetsUpToTestTimezone.new('Test/Zone', Time.utc(2012,8,1,0,0,0).to_i, Time.utc(2012,8,1,0,0,0).to_i, []). offsets_up_to(Time.utc(2012,8,1,0,0,0).to_i, Time.utc(2012,8,1,0,0,0).to_i) end assert_raises(ArgumentError) do OffsetsUpToTestTimezone.new('Test/Zone', DateTime.new(2012,8,1,0,0,0), DateTime.new(2012,8,1,0,0,0), []). offsets_up_to(DateTime.new(2012,8,1,0,0,0), DateTime.new(2012,8,1,0,0,0)) end end def test_now assert_kind_of(Time, Timezone.get('Europe/London').now) end def test_current_period assert_kind_of(TimezonePeriod, Timezone.get('Europe/London').current_period) end def test_current_period_and_time current = Timezone.get('Europe/London').current_period_and_time assert_equal(2, current.length) assert_kind_of(Time, current[0]) assert_kind_of(TimezonePeriod, current[1]) end def test_current_time_and_period current = Timezone.get('Europe/London').current_time_and_period assert_equal(2, current.length) assert_kind_of(Time, current[0]) assert_kind_of(TimezonePeriod, current[1]) end def test_compare assert_equal(0, TestTimezone.new('Europe/London') <=> TestTimezone.new('Europe/London')) assert_equal(-1, TestTimezone.new('Europe/London') <=> TestTimezone.new('Europe/london')) assert_equal(-1, TestTimezone.new('Europe/London') <=> TestTimezone.new('Europe/Paris')) assert_equal(1, TestTimezone.new('Europe/Paris') <=> TestTimezone.new('Europe/London')) assert_equal(-1, TestTimezone.new('America/New_York') <=> TestTimezone.new('Europe/Paris')) assert_equal(1, TestTimezone.new('Europe/Paris') <=> TestTimezone.new('America/New_York')) end def test_compare_non_comparable assert_nil(TestTimezone.new('Europe/London') <=> Object.new) end def test_equality assert_equal(true, TestTimezone.new('Europe/London') == TestTimezone.new('Europe/London')) assert_equal(false, TestTimezone.new('Europe/London') == TestTimezone.new('Europe/london')) assert_equal(false, TestTimezone.new('Europe/London') == TestTimezone.new('Europe/Paris')) assert(!(TestTimezone.new('Europe/London') == Object.new)) end def test_eql assert_equal(true, TestTimezone.new('Europe/London').eql?(TestTimezone.new('Europe/London'))) assert_equal(false, TestTimezone.new('Europe/London').eql?(TestTimezone.new('Europe/london'))) assert_equal(false, TestTimezone.new('Europe/London').eql?(TestTimezone.new('Europe/Paris'))) assert(!TestTimezone.new('Europe/London').eql?(Object.new)) end def test_hash assert_equal('Europe/London'.hash, TestTimezone.new('Europe/London').hash) assert_equal('America/New_York'.hash, TestTimezone.new('America/New_York').hash) end def test_marshal_data tz = Timezone.get('Europe/London') assert_kind_of(DataTimezone, tz) assert_same(tz, Marshal.load(Marshal.dump(tz))) end def test_marshal_linked tz = Timezone.get('UTC') # ZoneinfoDataSource doesn't return LinkedTimezoneInfo for any timezone. if DataSource.get.load_timezone_info('UTC').kind_of?(LinkedTimezoneInfo) assert_kind_of(LinkedTimezone, tz) else assert_kind_of(DataTimezone, tz) end assert_same(tz, Marshal.load(Marshal.dump(tz))) end def test_strftime_datetime tz = Timezone.get('Europe/London') assert_equal('23:12:02 BST', tz.strftime('%H:%M:%S %Z', DateTime.new(2006, 7, 15, 22, 12, 2))) assert_equal('BST', tz.strftime('%Z', DateTime.new(2006, 7, 15, 22, 12, 2))) assert_equal('%ZBST', tz.strftime('%%Z%Z', DateTime.new(2006, 7, 15, 22, 12, 2))) assert_equal('BST BST', tz.strftime('%Z %Z', DateTime.new(2006, 7, 15, 22, 12, 2))) end def test_strftime_time tz = Timezone.get('Europe/London') assert_equal('23:12:02 BST', tz.strftime('%H:%M:%S %Z', Time.utc(2006, 7, 15, 22, 12, 2))) assert_equal('BST', tz.strftime('%Z', Time.utc(2006, 7, 15, 22, 12, 2))) assert_equal('%ZBST', tz.strftime('%%Z%Z', Time.utc(2006, 7, 15, 22, 12, 2))) assert_equal('BST BST', tz.strftime('%Z %Z', Time.utc(2006, 7, 15, 22, 12, 2))) end def test_strftime_int tz = Timezone.get('Europe/London') assert_equal('23:12:02 BST', tz.strftime('%H:%M:%S %Z', Time.utc(2006, 7, 15, 22, 12, 2).to_i)) assert_equal('BST', tz.strftime('%Z', Time.utc(2006, 7, 15, 22, 12, 2).to_i)) assert_equal('%ZBST', tz.strftime('%%Z%Z', Time.utc(2006, 7, 15, 22, 12, 2).to_i)) assert_equal('BST BST', tz.strftime('%Z %Z', Time.utc(2006, 7, 15, 22, 12, 2).to_i)) end def test_get_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.get('Europe/London') end end def test_new_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.new('Europe/London') end end def test_all_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.all end end def test_all_identifiers_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.all_identifiers end end def test_all_data_zones_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.all_data_zones end end def test_all_data_zone_identifiers_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.all_data_zone_identifiers end end def test_all_linked_zones_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.all_linked_zones end end def test_all_linked_zone_identifiers_missing_data_source DataSource.set(DataSource.new) assert_raises(InvalidDataSource) do Timezone.all_linked_zone_identifiers end end end tzinfo-1.2.2/test/tc_timezone_offset.rb0000644000004100000410000001231612400401360020240 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneOffset < Minitest::Test def test_utc_offset o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(18000, o1.utc_offset) assert_equal(-3600, o2.utc_offset) end def test_std_offset o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(0, o1.std_offset) assert_equal(3600, o2.std_offset) end def test_utc_total_offset o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(18000, o1.utc_total_offset) assert_equal(0, o2.utc_total_offset) end def test_abbreviation o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(:TEST, o1.abbreviation) assert_equal(:TEST2, o2.abbreviation) end def test_dst o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(false, o1.dst?) assert_equal(true, o2.dst?) end def test_to_local o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(1148949080, o1.to_local(1148931080)) assert_equal(Time.utc(2006, 5, 30, 0, 31, 20), o1.to_local(Time.utc(2006, 5, 29, 19, 31, 20))) assert_equal(Time.utc(2006, 5, 30, 0, 31, 20, 782000), o1.to_local(Time.utc(2006, 5, 29, 19, 31, 20, 782000))) assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20), o1.to_local(DateTime.new(2006, 5, 29, 19, 31, 20))) assert_equal(DateTime.new(2006, 5, 30, 0, 31, 20 + Rational(782, 1000)), o1.to_local(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(782, 1000)))) assert_equal(1148949080, o1.to_local(1148931080)) assert(TimeOrDateTime.new(1148949080).eql?(o1.to_local(TimeOrDateTime.new(1148931080)))) assert_equal(1148931080, o2.to_local(1148931080)) assert_equal(Time.utc(2006, 5, 29, 19, 31, 20), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20))) assert_equal(Time.utc(2006, 5, 29, 19, 31, 20, 123000), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20, 123000))) assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20))) assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(123, 1000)), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(123, 1000)))) assert_equal(1148931080, o2.to_local(1148931080)) assert(TimeOrDateTime.new(1148931080).eql?(o2.to_local(TimeOrDateTime.new(1148931080)))) end def test_to_utc o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(1148913080, o1.to_utc(1148931080)) assert_equal(Time.utc(2006, 5, 29, 14, 31, 20), o1.to_utc(Time.utc(2006, 5, 29, 19, 31, 20))) assert_equal(Time.utc(2006, 5, 29, 14, 31, 20, 913000), o1.to_utc(Time.utc(2006, 5, 29, 19, 31, 20, 913000))) assert_equal(DateTime.new(2006, 5, 29, 14, 31, 20), o1.to_utc(DateTime.new(2006, 5, 29, 19, 31, 20))) assert_equal(DateTime.new(2006, 5, 29, 14, 31, 20 + Rational(913,1000)), o1.to_utc(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(913,1000)))) assert_equal(1148913080, o1.to_utc(1148931080)) assert(TimeOrDateTime.new(1148913080).eql?(o1.to_utc(TimeOrDateTime.new(1148931080)))) assert_equal(1148931080, o2.to_local(1148931080)) assert_equal(Time.utc(2006, 5, 29, 19, 31, 20), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20))) assert_equal(Time.utc(2006, 5, 29, 19, 31, 20, 323000), o2.to_local(Time.utc(2006, 5, 29, 19, 31, 20, 323000))) assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20))) assert_equal(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(323, 1000)), o2.to_local(DateTime.new(2006, 5, 29, 19, 31, 20 + Rational(323, 1000)))) assert_equal(1148931080, o2.to_utc(1148931080)) assert(TimeOrDateTime.new(1148931080).eql?(o2.to_local(TimeOrDateTime.new(1148931080)))) end def test_equality o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(18000, 0, :TEST) o3 = TimezoneOffset.new(18001, 0, :TEST) o4 = TimezoneOffset.new(18000, 1, :TEST) o5 = TimezoneOffset.new(18000, 0, :TEST2) assert_equal(true, o1 == o1) assert_equal(true, o1 == o2) assert_equal(false, o1 == o3) assert_equal(false, o1 == o4) assert_equal(false, o1 == o5) assert_equal(false, o1 == Object.new) end def test_eql o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(18000, 0, :TEST) o3 = TimezoneOffset.new(18001, 0, :TEST) o4 = TimezoneOffset.new(18000, 1, :TEST) o5 = TimezoneOffset.new(18000, 0, :TEST2) assert_equal(true, o1.eql?(o1)) assert_equal(true, o1.eql?(o2)) assert_equal(false, o1.eql?(o3)) assert_equal(false, o1.eql?(o4)) assert_equal(false, o1.eql?(o5)) assert_equal(false, o1.eql?(Object.new)) end def test_hash o1 = TimezoneOffset.new(18000, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST2) assert_equal(18000.hash ^ 0.hash ^ :TEST.hash, o1.hash) assert_equal(-3600.hash ^ 3600.hash ^ :TEST2.hash, o2.hash) end end tzinfo-1.2.2/test/tc_zoneinfo_data_source.rb0000644000004100000410000012137712400401360021250 0ustar www-datawww-data# encoding: UTF-8 require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') require 'fileutils' require 'pathname' require 'tmpdir' include TZInfo class TCZoneinfoDataSource < Minitest::Test ZONEINFO_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo').untaint def setup @orig_search_path = ZoneinfoDataSource.search_path.clone @orig_alternate_iso3166_tab_search_path = ZoneinfoDataSource.alternate_iso3166_tab_search_path.clone @orig_pwd = FileUtils.pwd # A zoneinfo directory containing files needed by the tests. # The symlinks in this directory are set up in test_utils.rb. @data_source = ZoneinfoDataSource.new(ZONEINFO_DIR) end def teardown ZoneinfoDataSource.search_path = @orig_search_path ZoneinfoDataSource.alternate_iso3166_tab_search_path = @orig_alternate_iso3166_tab_search_path FileUtils.chdir(@orig_pwd) end def test_default_search_path assert_equal(['/usr/share/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo'], ZoneinfoDataSource.search_path) assert_equal(false, ZoneinfoDataSource.search_path.frozen?) end def test_set_search_path_default ZoneinfoDataSource.search_path = ['/tmp/zoneinfo1', '/tmp/zoneinfo2'] assert_equal(['/tmp/zoneinfo1', '/tmp/zoneinfo2'], ZoneinfoDataSource.search_path) ZoneinfoDataSource.search_path = nil assert_equal(['/usr/share/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo'], ZoneinfoDataSource.search_path) assert_equal(false, ZoneinfoDataSource.search_path.frozen?) end def test_set_search_path_array path = ['/tmp/zoneinfo1', '/tmp/zoneinfo2'] ZoneinfoDataSource.search_path = path assert_equal(['/tmp/zoneinfo1', '/tmp/zoneinfo2'], ZoneinfoDataSource.search_path) refute_same(path, ZoneinfoDataSource.search_path) end def test_set_search_path_array_to_s ZoneinfoDataSource.search_path = [Pathname.new('/tmp/zoneinfo3')] assert_equal(['/tmp/zoneinfo3'], ZoneinfoDataSource.search_path) end def test_set_search_path_string ZoneinfoDataSource.search_path = ['/tmp/zoneinfo4', '/tmp/zoneinfo5'].join(File::PATH_SEPARATOR) assert_equal(['/tmp/zoneinfo4', '/tmp/zoneinfo5'], ZoneinfoDataSource.search_path) end def test_default_alternate_iso3166_tab_search_path assert_equal(['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166'], ZoneinfoDataSource.alternate_iso3166_tab_search_path) assert_equal(false, ZoneinfoDataSource.alternate_iso3166_tab_search_path.frozen?) end def test_set_alternate_iso3166_tab_search_path_default ZoneinfoDataSource.alternate_iso3166_tab_search_path = ['/tmp/iso3166.tab', '/tmp/iso3166'] assert_equal(['/tmp/iso3166.tab', '/tmp/iso3166'], ZoneinfoDataSource.alternate_iso3166_tab_search_path) ZoneinfoDataSource.alternate_iso3166_tab_search_path = nil assert_equal(['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166'], ZoneinfoDataSource.alternate_iso3166_tab_search_path) assert_equal(false, ZoneinfoDataSource.alternate_iso3166_tab_search_path.frozen?) end def test_set_alternate_iso3166_tab_search_path_array path = ['/tmp/iso3166.tab', '/tmp/iso3166'] ZoneinfoDataSource.alternate_iso3166_tab_search_path = path assert_equal(['/tmp/iso3166.tab', '/tmp/iso3166'], ZoneinfoDataSource.alternate_iso3166_tab_search_path) refute_same(path, ZoneinfoDataSource.alternate_iso3166_tab_search_path) end def test_set_alternate_iso3166_tab_search_path_array_to_s ZoneinfoDataSource.alternate_iso3166_tab_search_path = [Pathname.new('/tmp/iso3166.tab')] assert_equal(['/tmp/iso3166.tab'], ZoneinfoDataSource.alternate_iso3166_tab_search_path) end def test_set_alternate_iso3166_tab_search_path_string ZoneinfoDataSource.alternate_iso3166_tab_search_path = ['/tmp/iso3166.tab', '/tmp/iso3166'].join(File::PATH_SEPARATOR) assert_equal(['/tmp/iso3166.tab', '/tmp/iso3166'], ZoneinfoDataSource.alternate_iso3166_tab_search_path) end def test_new_search Dir.mktmpdir('tzinfo_test_dir1') do |dir1| Dir.mktmpdir('tzinfo_test_dir2') do |dir2| Dir.mktmpdir('tzinfo_test_dir3') do |dir3| Dir.mktmpdir('tzinfo_test_dir4') do |dir4| file = File.join(dir1, 'file') FileUtils.touch(File.join(dir2, 'zone.tab')) FileUtils.touch(File.join(dir3, 'iso3166.tab')) FileUtils.touch(File.join(dir4, 'zone.tab')) FileUtils.touch(File.join(dir4, 'iso3166.tab')) ZoneinfoDataSource.search_path = [file, dir2, dir3, dir4] ZoneinfoDataSource.alternate_iso3166_tab_search_path = [] data_source = ZoneinfoDataSource.new assert_equal(dir4, data_source.zoneinfo_dir) end end end end end def test_new_search_zone1970 Dir.mktmpdir('tzinfo_test_dir1') do |dir1| Dir.mktmpdir('tzinfo_test_dir2') do |dir2| Dir.mktmpdir('tzinfo_test_dir3') do |dir3| Dir.mktmpdir('tzinfo_test_dir4') do |dir4| file = File.join(dir1, 'file') FileUtils.touch(File.join(dir2, 'zone1970.tab')) FileUtils.touch(File.join(dir3, 'iso3166.tab')) FileUtils.touch(File.join(dir4, 'zone1970.tab')) FileUtils.touch(File.join(dir4, 'iso3166.tab')) ZoneinfoDataSource.search_path = [file, dir2, dir3, dir4] ZoneinfoDataSource.alternate_iso3166_tab_search_path = [] data_source = ZoneinfoDataSource.new assert_equal(dir4, data_source.zoneinfo_dir) end end end end end def test_new_search_solaris_tab_files # Solaris names the tab files 'tab/country.tab' (iso3166.tab) and # 'tab/zone_sun.tab' (zone.tab). Dir.mktmpdir('tzinfo_test_dir') do |dir| tab = File.join(dir, 'tab') FileUtils.mkdir(tab) FileUtils.touch(File.join(tab, 'country.tab')) FileUtils.touch(File.join(tab, 'zone_sun.tab')) ZoneinfoDataSource.search_path = [dir] ZoneinfoDataSource.alternate_iso3166_tab_search_path = [] data_source = ZoneinfoDataSource.new assert_equal(dir, data_source.zoneinfo_dir) end end def test_new_search_alternate_iso3166_path Dir.mktmpdir('tzinfo_test_dir_zoneinfo') do |zoneinfo_dir| Dir.mktmpdir('tzinfo_test_dir_tab') do |tab_dir| FileUtils.touch(File.join(zoneinfo_dir, 'zone.tab')) tab_file = File.join(tab_dir, 'iso3166') ZoneinfoDataSource.search_path = [zoneinfo_dir] ZoneinfoDataSource.alternate_iso3166_tab_search_path = [tab_file] assert_raises(ZoneinfoDirectoryNotFound) do ZoneinfoDataSource.new end FileUtils.touch(tab_file) data_source = ZoneinfoDataSource.new assert_equal(zoneinfo_dir, data_source.zoneinfo_dir) end end end def test_new_search_not_found Dir.mktmpdir('tzinfo_test_dir1') do |dir1| Dir.mktmpdir('tzinfo_test_dir2') do |dir2| Dir.mktmpdir('tzinfo_test_dir3') do |dir3| Dir.mktmpdir('tzinfo_test_dir4') do |dir4| Dir.mktmpdir('tzinfo_test_dir5') do |dir5| file = File.join(dir1, 'file') FileUtils.touch(file) FileUtils.touch(File.join(dir2, 'zone.tab')) FileUtils.touch(File.join(dir3, 'zone1970.tab')) FileUtils.touch(File.join(dir4, 'iso3166.tab')) ZoneinfoDataSource.search_path = [file, dir2, dir3, dir4, dir5] ZoneinfoDataSource.alternate_iso3166_tab_search_path = [] assert_raises(ZoneinfoDirectoryNotFound) do ZoneinfoDataSource.new end end end end end end end def test_new_search_relative Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.chdir(dir) ZoneinfoDataSource.search_path = ['.'] ZoneinfoDataSource.alternate_iso3166_tab_search_path = [] data_source = ZoneinfoDataSource.new assert_equal(Pathname.new(dir).realpath.to_s, data_source.zoneinfo_dir) # Change out of the directory to allow it to be deleted on Windows. FileUtils.chdir(@orig_pwd) end end def test_new_dir Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) data_source = ZoneinfoDataSource.new(dir) assert_equal(dir, data_source.zoneinfo_dir) end end def test_new_dir_zone1970 Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone1970.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) data_source = ZoneinfoDataSource.new(dir) assert_equal(dir, data_source.zoneinfo_dir) end end def test_new_dir_solaris_tab_files # Solaris names the tab files 'tab/country.tab' (iso3166.tab) and # 'tab/zone_sun.tab' (zone.tab). Dir.mktmpdir('tzinfo_test') do |dir| tab = File.join(dir, 'tab') FileUtils.mkdir(tab) FileUtils.touch(File.join(tab, 'country.tab')) FileUtils.touch(File.join(tab, 'zone_sun.tab')) data_source = ZoneinfoDataSource.new(dir) assert_equal(dir, data_source.zoneinfo_dir) end end def test_new_dir_alternate_iso3166_path Dir.mktmpdir('tzinfo_test_dir_zoneinfo') do |zoneinfo_dir| Dir.mktmpdir('tzinfo_test_dir_tab') do |tab_dir| FileUtils.touch(File.join(zoneinfo_dir, 'zone.tab')) tab_file = File.join(tab_dir, 'iso3166') FileUtils.touch(tab_file) ZoneinfoDataSource.alternate_iso3166_tab_search_path = [tab_file] assert_raises(InvalidZoneinfoDirectory) do # The alternate_iso3166_tab_search_path should not be used. This should raise # an exception. ZoneinfoDataSource.new(zoneinfo_dir) end data_source = ZoneinfoDataSource.new(zoneinfo_dir, tab_file) assert_equal(zoneinfo_dir, data_source.zoneinfo_dir) end end end def test_new_dir_invalid Dir.mktmpdir('tzinfo_test') do |dir| assert_raises(InvalidZoneinfoDirectory) do ZoneinfoDataSource.new(dir) end end end def test_new_dir_invalid_alternate_iso3166_path Dir.mktmpdir('tzinfo_test_dir_zoneinfo') do |zoneinfo_dir| Dir.mktmpdir('tzinfo_test_dir_tab') do |tab_dir| FileUtils.touch(File.join(zoneinfo_dir, 'zone.tab')) assert_raises(InvalidZoneinfoDirectory) do ZoneinfoDataSource.new(zoneinfo_dir, File.join(tab_dir, 'iso3166')) end end end end def test_new_dir_invalid_alternate_iso3166_path_overrides_valid Dir.mktmpdir('tzinfo_test_dir_zoneinfo') do |zoneinfo_dir| Dir.mktmpdir('tzinfo_test_dir_tab') do |tab_dir| FileUtils.touch(File.join(zoneinfo_dir, 'iso3166.tab')) FileUtils.touch(File.join(zoneinfo_dir, 'zone.tab')) assert_raises(InvalidZoneinfoDirectory) do ZoneinfoDataSource.new(zoneinfo_dir, File.join(tab_dir, 'iso3166')) end end end end def test_new_file Dir.mktmpdir('tzinfo_test') do |dir| file = File.join(dir, 'file') FileUtils.touch(file) assert_raises(InvalidZoneinfoDirectory) do ZoneinfoDataSource.new(file) end end end def test_new_dir_relative Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.chdir(dir) data_source = ZoneinfoDataSource.new('.') assert_equal(Pathname.new(dir).realpath.to_s, data_source.zoneinfo_dir) # Change out of the directory to allow it to be deleted on Windows. FileUtils.chdir(@orig_pwd) end end def test_zoneinfo_dir Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) data_source = ZoneinfoDataSource.new(dir) assert_equal(dir, data_source.zoneinfo_dir) assert_equal(true, data_source.zoneinfo_dir.frozen?) end end def test_load_timezone_info_data info = @data_source.load_timezone_info('Europe/London') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Europe/London', info.identifier) end def test_load_timezone_info_linked info = @data_source.load_timezone_info('UTC') # On platforms that don't support symlinks, 'UTC' will be created as a copy. # Either way, a ZoneinfoTimezoneInfo should be returned. assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('UTC', info.identifier) end def test_load_timezone_info_does_not_exist assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('Nowhere/Special') end end def test_load_timezone_info_invalid assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('../Definitions/Europe/London') end end def test_load_timezone_info_ignored_file assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('localtime') end end def test_load_timezone_info_ignored_plus_version_file # Mac OS X includes a file named +VERSION containing the tzdata version. Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) File.open(File.join(dir, '+VERSION'), 'w') do |f| f.binmode f.write("2013a\n") end data_source = ZoneinfoDataSource.new(dir) assert_raises(InvalidTimezoneIdentifier) do data_source.load_timezone_info('+VERSION') end end end def test_load_timezone_info_nil assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info(nil) end end def test_load_timezone_info_case assert_raises(InvalidTimezoneIdentifier) do @data_source.load_timezone_info('europe/london') end end def test_load_timezone_info_permission_denied Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) file = File.join(dir, 'UTC') FileUtils.touch(file) FileUtils.chmod(0200, file) data_source = ZoneinfoDataSource.new(dir) assert_raises(InvalidTimezoneIdentifier) do data_source.load_timezone_info('UTC') end end end def test_load_timezone_info_directory Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) subdir = File.join(dir, 'Subdir') FileUtils.mkdir(subdir) data_source = ZoneinfoDataSource.new(dir) assert_raises(InvalidTimezoneIdentifier) do data_source.load_timezone_info('Subdir') end end end def test_load_timezone_info_linked_absolute_outside Dir.mktmpdir('tzinfo_test') do |dir| Dir.mktmpdir('tzinfo_test') do |outside| outside_file = File.join(outside, 'EST') FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), outside_file) FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) file = File.join(dir, 'EST') begin FileUtils.ln_s(outside_file, file) rescue NotImplementedError # Symlinks not supported on this platform - skip test return end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_timezone_info('EST') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('EST', info.identifier) end end end def test_load_timezone_info_linked_absolute_inside Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(dir, 'EST')) link = File.join(dir, 'Link') begin FileUtils.ln_s(File.join(File.expand_path(dir), 'EST'), link) rescue NotImplementedError # Symlinks not supported on this platform - skip test return end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_timezone_info('Link') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Link', info.identifier) end end def test_load_timezone_info_linked_relative_outside Dir.mktmpdir('tzinfo_test') do |root| FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(root, 'outside')) dir = File.join(root, 'zoneinfo') FileUtils.mkdir(dir) FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) link = File.join(dir, 'Link') begin FileUtils.ln_s('../outside', link) rescue NotImplementedError # Symlinks not supported on this platform - skip test return end subdir = File.join(dir, 'Subdir') subdir_link = File.join(subdir, 'Link') FileUtils.mkdir(subdir) FileUtils.ln_s('../../outside', subdir_link) data_source = ZoneinfoDataSource.new(dir) info = data_source.load_timezone_info('Link') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Link', info.identifier) info = data_source.load_timezone_info('Subdir/Link') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Subdir/Link', info.identifier) end end def test_load_timezone_info_linked_relative_parent_inside Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(dir, 'EST')) subdir = File.join(dir, 'Subdir') FileUtils.mkdir(subdir) FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(subdir, 'EST')) subdir_link = File.join(subdir, 'Link') begin FileUtils.ln_s('../Subdir/EST', subdir_link) rescue NotImplementedError # Symlinks not supported on this platform - skip test return end subdir_link2 = File.join(subdir, 'Link2') FileUtils.ln_s('../EST', subdir_link2) subdir2 = File.join(dir, 'Subdir2') FileUtils.mkdir(subdir2) subdir2_link = File.join(subdir2, 'Link') FileUtils.ln_s('../Subdir/EST', subdir2_link) data_source = ZoneinfoDataSource.new(dir) info = data_source.load_timezone_info('Subdir/Link') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Subdir/Link', info.identifier) info = data_source.load_timezone_info('Subdir/Link2') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Subdir/Link2', info.identifier) info = data_source.load_timezone_info('Subdir2/Link') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Subdir2/Link', info.identifier) end end def test_load_timezone_info_invalid_file Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) File.open(File.join(dir, 'Zone'), 'wb') do |file| file.write('NotAValidTZifFile') end data_source = ZoneinfoDataSource.new(dir) assert_raises(InvalidTimezoneIdentifier) do data_source.load_timezone_info('Zone') end end end def test_load_timezone_info_invalid_file_2 Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) zone = File.join(dir, 'Zone') File.open(File.join(@data_source.zoneinfo_dir, 'EST')) do |src| # Change header to TZif1 (which is not a valid header). File.open(zone, 'wb') do |dest| dest.write('TZif1') src.pos = 5 FileUtils.copy_stream(src, dest) end end data_source = ZoneinfoDataSource.new(dir) assert_raises(InvalidTimezoneIdentifier) do data_source.load_timezone_info('Zone') end end end def test_load_timezone_info_tainted safe_test do identifier = 'Europe/Amsterdam'.taint assert(identifier.tainted?) info = @data_source.load_timezone_info(identifier) assert_equal('Europe/Amsterdam', info.identifier) assert(identifier.tainted?) end end def test_load_timezone_info_tainted_and_frozen safe_test do info = @data_source.load_timezone_info('Europe/Amsterdam'.taint.freeze) assert_equal('Europe/Amsterdam', info.identifier) end end def test_load_timezone_info_tainted_zoneinfo_dir_safe_mode safe_test(:unavailable => :skip) do assert_raises(SecurityError) do ZoneinfoDataSource.new(@data_source.zoneinfo_dir.dup.taint) end end end def test_load_timezone_info_tainted_zoneinfo_dir data_source = ZoneinfoDataSource.new(@data_source.zoneinfo_dir.dup.taint) info = data_source.load_timezone_info('Europe/London') assert_kind_of(ZoneinfoTimezoneInfo, info) assert_equal('Europe/London', info.identifier) end def get_timezone_filenames(directory) entries = Dir.glob(File.join(directory, '**', '*')) entries = entries.select do |file| file.untaint File.file?(file) end entries = entries.collect {|file| file[directory.length + File::SEPARATOR.length, file.length - directory.length - File::SEPARATOR.length]} # Exclude right (with leapseconds) and posix (copy) directories; .tab files; localtime, posixrules and Factory zones entries = entries.select do |file| file !~ /\A(posix|right)\// && file !~ /\.tab\z/ && !%w(localtime posixrules Factory).include?(file) end entries.sort end def test_timezone_identifiers expected = get_timezone_filenames(@data_source.zoneinfo_dir) all = @data_source.timezone_identifiers assert_kind_of(Array, all) assert_array_same_items(expected, all) assert_equal(true, all.frozen?) end def test_data_timezone_identifiers expected = get_timezone_filenames(@data_source.zoneinfo_dir) all_data = @data_source.data_timezone_identifiers assert_kind_of(Array, all_data) assert_array_same_items(expected, all_data) assert_equal(true, all_data.frozen?) end def test_linked_timezone_identifiers all_linked = @data_source.linked_timezone_identifiers assert_kind_of(Array, all_linked) assert_equal(true, all_linked.empty?) assert_equal(true, all_linked.frozen?) end def test_timezone_identifiers_safe_mode safe_test do expected = get_timezone_filenames(@data_source.zoneinfo_dir) all = @data_source.timezone_identifiers assert_kind_of(Array, all) assert_array_same_items(expected, all) assert_equal(true, all.frozen?) end end def test_timezone_identifiers_ignored_plus_version_file # Mac OS X includes a file named +VERSION containing the tzdata version. Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(dir, 'EST')) File.open(File.join(dir, '+VERSION'), 'w') do |f| f.binmode f.write("2013a\n") end data_source = ZoneinfoDataSource.new(dir) assert_array_same_items(['EST'], data_source.timezone_identifiers) end end def test_timezone_identifiers_ignored_src_directory # Solaris includes a src directory containing the source timezone data files # from the tzdata distribution. These should be ignored. Dir.mktmpdir('tzinfo_test') do |dir| FileUtils.touch(File.join(dir, 'zone.tab')) FileUtils.touch(File.join(dir, 'iso3166.tab')) FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(dir, 'EST')) src_dir = File.join(dir, 'src') FileUtils.mkdir(src_dir) File.open(File.join(src_dir, 'europe'), 'w') do |f| f.binmode f.write("Zone\tEurope/London\t0:00\tEU\tGMT/BST\n") end data_source = ZoneinfoDataSource.new(dir) assert_array_same_items(['EST'], data_source.timezone_identifiers) end end def test_load_country_info info = @data_source.load_country_info('GB') assert_equal('GB', info.code) assert_equal('Britain (UK)', info.name) end def test_load_country_info_not_exist assert_raises(InvalidCountryCode) do @data_source.load_country_info('ZZ') end end def test_load_country_info_invalid assert_raises(InvalidCountryCode) do @data_source.load_country_info('../Countries/GB') end end def test_load_country_info_nil assert_raises(InvalidCountryCode) do @data_source.load_country_info(nil) end end def test_load_country_info_case assert_raises(InvalidCountryCode) do @data_source.load_country_info('gb') end end def test_load_country_info_tainted safe_test do code = 'NL'.taint assert(code.tainted?) info = @data_source.load_country_info(code) assert_equal('NL', info.code) assert(code.tainted?) end end def test_load_country_info_tainted_and_frozen safe_test do info = @data_source.load_country_info('NL'.taint.freeze) assert_equal('NL', info.code) end end def test_load_country_info_check_zones Dir.mktmpdir('tzinfo_test') do |dir| RubyCoreSupport.open_file(File.join(dir, 'iso3166.tab'), 'w', :external_encoding => 'UTF-8') do |iso3166| iso3166.puts('# iso3166.tab') iso3166.puts('') iso3166.puts("FC\tFake Country") iso3166.puts("OC\tOther Country") end RubyCoreSupport.open_file(File.join(dir, 'zone.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts('# zone.tab') zone.puts('') zone.puts("FC\t+513030-0000731\tFake/One\tDescription of one") zone.puts("FC\t+353916+1394441\tFake/Two\tAnother description") zone.puts("FC\t-2332-04637\tFake/Three\tThis is Three") zone.puts("OC\t+5005+01426\tOther/One") end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_country_info('FC') assert_equal('FC', info.code) assert_equal('Fake Country', info.name) assert_equal(['Fake/One', 'Fake/Two', 'Fake/Three'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([ CountryTimezone.new('Fake/One', Rational(6181, 120), Rational(-451, 3600), 'Description of one'), CountryTimezone.new('Fake/Two', Rational(32089, 900), Rational(503081, 3600), 'Another description'), CountryTimezone.new('Fake/Three', Rational(-353, 15), Rational(-2797, 60), 'This is Three')], info.zones) assert_equal(true, info.zones.frozen?) info = data_source.load_country_info('OC') assert_equal('OC', info.code) assert_equal('Other Country', info.name) assert_equal(['Other/One'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([CountryTimezone.new('Other/One', Rational(601, 12), Rational(433, 30))], info.zones) assert_equal(true, info.zones.frozen?) end end def test_load_country_info_check_zones_zone1970 Dir.mktmpdir('tzinfo_test') do |dir| RubyCoreSupport.open_file(File.join(dir, 'iso3166.tab'), 'w', :external_encoding => 'UTF-8') do |iso3166| iso3166.puts('# iso3166.tab') iso3166.puts('') iso3166.puts("AC\tAnother Country") iso3166.puts("FC\tFake Country") iso3166.puts("OC\tOther Country") end # zone.tab will be ignored. RubyCoreSupport.open_file(File.join(dir, 'zone.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts('# zone.tab') zone.puts('') zone.puts("FC\t+513030-0000731\tFake/One\tDescription of one") zone.puts("FC\t+353916+1394441\tFake/Two\tAnother description") zone.puts("FC\t-2332-04637\tFake/Three\tThis is Three") zone.puts("OC\t+5005+01426\tOther/One") end # zone1970.tab will be used. RubyCoreSupport.open_file(File.join(dir, 'zone1970.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts('# zone1970.tab') zone.puts('') zone.puts("AC,OC\t+0000+00000\tMiddle/Another/One\tAnother's One") zone.puts("FC\t+513030-0000731\tFake/One\tDescription of one") zone.puts("FC,OC\t+353916+1394441\tFake/Two\tAnother description") zone.puts("FC,OC\t-2332-04637\tFake/Three\tThis is Three") zone.puts("OC\t+5005+01426\tOther/One") zone.puts("OC\t+5015+11426\tOther/Two") end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_country_info('AC') assert_equal('AC', info.code) assert_equal('Another Country', info.name) assert_equal(['Middle/Another/One'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([CountryTimezone.new('Middle/Another/One', Rational(0, 1), Rational(0, 1), "Another's One")], info.zones) assert_equal(true, info.zones.frozen?) info = data_source.load_country_info('FC') assert_equal('FC', info.code) assert_equal('Fake Country', info.name) assert_equal(['Fake/One', 'Fake/Two', 'Fake/Three'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([ CountryTimezone.new('Fake/One', Rational(6181, 120), Rational(-451, 3600), 'Description of one'), CountryTimezone.new('Fake/Two', Rational(32089, 900), Rational(503081, 3600), 'Another description'), CountryTimezone.new('Fake/Three', Rational(-353, 15), Rational(-2797, 60), 'This is Three')], info.zones) assert_equal(true, info.zones.frozen?) # Testing the ordering of zones. A zone can either be primary (country # code is the first in the first column), or secondary (country code is # not the first). Should return all the primaries first in the order they # appeared in the file, followed by all the secondaries in the order they # appeared in file. info = data_source.load_country_info('OC') assert_equal('OC', info.code) assert_equal('Other Country', info.name) assert_equal(['Other/One', 'Other/Two', 'Middle/Another/One', 'Fake/Two', 'Fake/Three'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([ CountryTimezone.new('Other/One', Rational(601, 12), Rational( 433, 30)), CountryTimezone.new('Other/Two', Rational(201, 4), Rational(3433, 30)), CountryTimezone.new('Middle/Another/One', Rational(0, 1), Rational(0, 1), "Another's One"), CountryTimezone.new('Fake/Two', Rational(32089, 900), Rational(503081, 3600), 'Another description'), CountryTimezone.new('Fake/Three', Rational(-353, 15), Rational(-2797, 60), 'This is Three')], info.zones) assert_equal(true, info.zones.frozen?) end end def test_load_country_info_check_zones_solaris_tab_files # Solaris uses 5 columns instead of the usual 4 in zone_sun.tab. # An extra column before the comment gives an optional linked/alternate # timezone identifier (or '-' if not set). # # Additionally, there is a section at the end of the file for timezones # covering regions. These are given lower-case "country" codes. The timezone # identifier column refers to a continent instead of an identifier. These # lines will be ignored by TZInfo. Dir.mktmpdir('tzinfo_test') do |dir| tab_dir = File.join(dir, 'tab') FileUtils.mkdir(tab_dir) RubyCoreSupport.open_file(File.join(tab_dir, 'country.tab'), 'w', :external_encoding => 'UTF-8') do |country| country.puts('# country.tab') country.puts('# Solaris') country.puts("FC\tFake Country") country.puts("OC\tOther Country") end RubyCoreSupport.open_file(File.join(tab_dir, 'zone_sun.tab'), 'w', :external_encoding => 'UTF-8') do |zone_sun| zone_sun.puts('# zone_sun.tab') zone_sun.puts('# Solaris') zone_sun.puts('# Countries') zone_sun.puts("FC\t+513030-0000731\tFake/One\t-\tDescription of one") zone_sun.puts("FC\t+353916+1394441\tFake/Two\tFake/Alias/Two\tAnother description") zone_sun.puts("FC\t-2332-04637\tFake/Three\tFake/Alias/Three\tThis is Three") zone_sun.puts("OC\t+5005+01426\tOther/One\tOther/Linked/One") zone_sun.puts("OC\t+5015+01436\tOther/Two\t-") zone_sun.puts('# Regions') zone_sun.puts("ee\t+0000+00000\tEurope/\tEET") zone_sun.puts("me\t+0000+00000\tEurope/\tMET") zone_sun.puts("we\t+0000+00000\tEurope/\tWET") end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_country_info('FC') assert_equal('FC', info.code) assert_equal('Fake Country', info.name) assert_equal(['Fake/One', 'Fake/Two', 'Fake/Three'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([ CountryTimezone.new('Fake/One', Rational(6181, 120), Rational(-451, 3600), 'Description of one'), CountryTimezone.new('Fake/Two', Rational(32089, 900), Rational(503081, 3600), 'Another description'), CountryTimezone.new('Fake/Three', Rational(-353, 15), Rational(-2797, 60), 'This is Three')], info.zones) assert_equal(true, info.zones.frozen?) info = data_source.load_country_info('OC') assert_equal('OC', info.code) assert_equal('Other Country', info.name) assert_equal(['Other/One', 'Other/Two'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([ CountryTimezone.new('Other/One', Rational(601, 12), Rational(433, 30)), CountryTimezone.new('Other/Two', Rational(201, 4), Rational(73, 5))], info.zones) assert_equal(true, info.zones.frozen?) end end def test_load_country_info_check_zones_alternate_iso3166_file Dir.mktmpdir('tzinfo_test') do |dir| zoneinfo_dir = File.join(dir, 'zoneinfo') tab_dir = File.join(dir, 'tab') FileUtils.mkdir(zoneinfo_dir) FileUtils.mkdir(tab_dir) tab_file = File.join(tab_dir, 'iso3166') RubyCoreSupport.open_file(tab_file, 'w', :external_encoding => 'UTF-8') do |iso3166| # Use the BSD 4 column format (alternate iso3166 is used on BSD). iso3166.puts("FC\tFCC\t001\tFake Country") iso3166.puts("OC\tOCC\t002\tOther Country") end RubyCoreSupport.open_file(File.join(zoneinfo_dir, 'zone.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts("FC\t+513030-0000731\tFake/One\tDescription of one") zone.puts("FC\t+353916+1394441\tFake/Two\tAnother description") zone.puts("FC\t-2332-04637\tFake/Three\tThis is Three") zone.puts("OC\t+5005+01426\tOther/One") end data_source = ZoneinfoDataSource.new(zoneinfo_dir, tab_file) info = data_source.load_country_info('FC') assert_equal('FC', info.code) assert_equal('Fake Country', info.name) assert_equal(['Fake/One', 'Fake/Two', 'Fake/Three'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([ CountryTimezone.new('Fake/One', Rational(6181, 120), Rational(-451, 3600), 'Description of one'), CountryTimezone.new('Fake/Two', Rational(32089, 900), Rational(503081, 3600), 'Another description'), CountryTimezone.new('Fake/Three', Rational(-353, 15), Rational(-2797, 60), 'This is Three')], info.zones) assert_equal(true, info.zones.frozen?) info = data_source.load_country_info('OC') assert_equal('OC', info.code) assert_equal('Other Country', info.name) assert_equal(['Other/One'], info.zone_identifiers) assert_equal(true, info.zone_identifiers.frozen?) assert_equal([CountryTimezone.new('Other/One', Rational(601, 12), Rational(433, 30))], info.zones) assert_equal(true, info.zones.frozen?) end end def test_load_country_info_four_column_iso31611 # OpenBSD and FreeBSD use a 4 column iso3166.tab file that includes # alpha-3 and numeric-3 codes in addition to the alpha-2 and name in the # tz database version. Dir.mktmpdir('tzinfo_test') do |dir| RubyCoreSupport.open_file(File.join(dir, 'iso3166.tab'), 'w', :external_encoding => 'UTF-8') do |iso3166| iso3166.puts("FC\tFCC\t001\tFake Country") iso3166.puts("OC\tOCC\t002\tOther Country") end RubyCoreSupport.open_file(File.join(dir, 'zone.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts("FC\t+513030-0000731\tFake/One\tDescription of one") zone.puts("OC\t+5005+01426\tOther/One") end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_country_info('FC') assert_equal('FC', info.code) assert_equal('Fake Country', info.name) info = data_source.load_country_info('OC') assert_equal('OC', info.code) assert_equal('Other Country', info.name) end end def test_load_country_info_utf8 # iso3166.tab is currently in ASCII (as of tzdata 2014f), but will be # changed to UTF-8 in the future. # zone.tab is in ASCII, with no plans to change. Since ASCII is a subset of # UTF-8, test that this is loaded in UTF-8 anyway. Dir.mktmpdir('tzinfo_test') do |dir| RubyCoreSupport.open_file(File.join(dir, 'iso3166.tab'), 'w', :external_encoding => 'UTF-8') do |iso3166| iso3166.puts("UT\tUnicode Test ✓") end RubyCoreSupport.open_file(File.join(dir, 'zone.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts("UT\t+513030-0000731\tUnicode✓/One\tUnicode Description ✓") end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_country_info('UT') assert_equal('UT', info.code) assert_equal('Unicode Test ✓', info.name) assert_equal(['Unicode✓/One'], info.zone_identifiers) assert_equal([CountryTimezone.new('Unicode✓/One', Rational(6181, 120), Rational(-451, 3600), 'Unicode Description ✓')], info.zones) end end def test_load_country_info_utf8_zone1970 # iso3166.tab is currently in ASCII (as of tzdata 2014f), but will be # changed to UTF-8 in the future. # zone1970.tab is in UTF-8. Dir.mktmpdir('tzinfo_test') do |dir| RubyCoreSupport.open_file(File.join(dir, 'iso3166.tab'), 'w', :external_encoding => 'UTF-8') do |iso3166| iso3166.puts("UT\tUnicode Test ✓") end RubyCoreSupport.open_file(File.join(dir, 'zone1970.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts("UT\t+513030-0000731\tUnicode✓/One\tUnicode Description ✓") end data_source = ZoneinfoDataSource.new(dir) info = data_source.load_country_info('UT') assert_equal('UT', info.code) assert_equal('Unicode Test ✓', info.name) assert_equal(['Unicode✓/One'], info.zone_identifiers) assert_equal([CountryTimezone.new('Unicode✓/One', Rational(6181, 120), Rational(-451, 3600), 'Unicode Description ✓')], info.zones) end end def test_country_codes file_codes = [] RubyCoreSupport.open_file(File.join(@data_source.zoneinfo_dir, 'iso3166.tab'), 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file| file.each_line do |line| line.chomp! file_codes << $1 if line =~ /\A([A-Z]{2})\t/ end end codes = @data_source.country_codes assert_array_same_items(file_codes, codes) assert_equal(true, codes.frozen?) end def test_country_codes_four_column_iso3166 # OpenBSD and FreeBSD use a 4 column iso3166.tab file that includes # alpha-3 and numeric-3 codes in addition to the alpha-2 and name in the # tz database version. Dir.mktmpdir('tzinfo_test') do |dir| RubyCoreSupport.open_file(File.join(dir, 'iso3166.tab'), 'w', :external_encoding => 'UTF-8') do |iso3166| iso3166.puts("FC\tFCC\t001\tFake Country") iso3166.puts("OC\tOCC\t002\tOther Country") end RubyCoreSupport.open_file(File.join(dir, 'zone.tab'), 'w', :external_encoding => 'UTF-8') do |zone| zone.puts("FC\t+513030-0000731\tFake/One\tDescription of one") zone.puts("OC\t+5005+01426\tOther/One") end data_source = ZoneinfoDataSource.new(dir) codes = data_source.country_codes assert_array_same_items(%w(FC OC), codes) end end end tzinfo-1.2.2/test/tc_ruby_country_info.rb0000644000004100000410000000437312400401360020623 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCRubyCountryInfo < Minitest::Test def test_code ci = RubyCountryInfo.new('ZZ', 'Zzz') {|c| } assert_equal('ZZ', ci.code) end def test_name ci = RubyCountryInfo.new('ZZ', 'Zzz') {|c| } assert_equal('Zzz', ci.name) end def test_zone_identifiers_empty ci = RubyCountryInfo.new('ZZ', 'Zzz') {|c| } assert(ci.zone_identifiers.empty?) assert(ci.zone_identifiers.frozen?) end def test_zone_identifiers_no_block ci = RubyCountryInfo.new('ZZ', 'Zzz') assert(ci.zone_identifiers.empty?) assert(ci.zone_identifiers.frozen?) end def test_zone_identifiers ci = RubyCountryInfo.new('ZZ', 'Zzz') do |c| c.timezone('ZZ/TimezoneB', 1, 2, 1, 2, 'Timezone B') c.timezone('ZZ/TimezoneA', 1, 4, 1, 4, 'Timezone A') c.timezone('ZZ/TimezoneC', -10, 3, -20, 7, 'C') c.timezone('ZZ/TimezoneD', -10, 3, -20, 7) end assert_equal(['ZZ/TimezoneB', 'ZZ/TimezoneA', 'ZZ/TimezoneC', 'ZZ/TimezoneD'], ci.zone_identifiers) assert(ci.zone_identifiers.frozen?) end def test_zones_empty ci = RubyCountryInfo.new('ZZ', 'Zzz') {|c| } assert(ci.zones.empty?) assert(ci.zones.frozen?) end def test_zones_no_block ci = RubyCountryInfo.new('ZZ', 'Zzz') assert(ci.zones.empty?) assert(ci.zones.frozen?) end def test_zones ci = RubyCountryInfo.new('ZZ', 'Zzz') do |c| c.timezone('ZZ/TimezoneB', 1, 2, 1, 2, 'Timezone B') c.timezone('ZZ/TimezoneA', 1, 4, 1, 4, 'Timezone A') c.timezone('ZZ/TimezoneC', -10, 3, -20, 7, 'C') c.timezone('ZZ/TimezoneD', -10, 3, -20, 7) end assert_equal([CountryTimezone.new!('ZZ/TimezoneB', 1, 2, 1, 2, 'Timezone B'), CountryTimezone.new!('ZZ/TimezoneA', 1, 4, 1, 4, 'Timezone A'), CountryTimezone.new!('ZZ/TimezoneC', -10, 3, -20, 7, 'C'), CountryTimezone.new!('ZZ/TimezoneD', -10, 3, -20, 7)], ci.zones) assert(ci.zones.frozen?) end def test_deferred_evaluate block_called = false ci = RubyCountryInfo.new('ZZ', 'Zzz') do |c| block_called = true end assert_equal(false, block_called) ci.zones assert_equal(true, block_called) end end tzinfo-1.2.2/test/tc_timezone_period.rb0000644000004100000410000005620612400401360020242 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezonePeriod < Minitest::Test class TestTimezoneTransition < TimezoneTransition def initialize(offset, previous_offset, at) super(offset, previous_offset) @at = TimeOrDateTime.wrap(at) end def at @at end end def test_initialize_start_end std = TimezoneOffset.new(-7200, 0, :TEST) dst = TimezoneOffset.new(-7200, 3600, :TEST) start_t = TestTimezoneTransition.new(dst, std, 1136073600) end_t = TestTimezoneTransition.new(std, dst, 1136160000) p = TimezonePeriod.new(start_t, end_t) assert_same(start_t, p.start_transition) assert_same(end_t, p.end_transition) assert_same(dst, p.offset) assert_equal(DateTime.new(2006,1,1,0,0,0), p.utc_start) assert_equal(Time.utc(2006,1,1,0,0,0), p.utc_start_time) assert_equal(DateTime.new(2006,1,2,0,0,0), p.utc_end) assert_equal(Time.utc(2006,1,2,0,0,0), p.utc_end_time) assert_equal(-7200, p.utc_offset) assert_equal(3600, p.std_offset) assert_equal(-3600, p.utc_total_offset) assert_equal(Rational(-3600, 86400), p.utc_total_offset_rational) assert_equal(:TEST, p.zone_identifier) assert_equal(:TEST, p.abbreviation) assert_equal(DateTime.new(2005,12,31,23,0,0), p.local_start) assert_equal(Time.utc(2005,12,31,23,0,0), p.local_start_time) assert_equal(DateTime.new(2006,1,1,23,0,0), p.local_end) assert_equal(Time.utc(2006,1,1,23,0,0), p.local_end_time) end def test_initialize_start_end_offset std = TimezoneOffset.new(-7200, 0, :TEST) dst = TimezoneOffset.new(-7200, 3600, :TEST) special = TimezoneOffset.new(0, 0, :SPECIAL) start_t = TestTimezoneTransition.new(dst, std, 1136073600) end_t = TestTimezoneTransition.new(std, dst, 1136160000) assert_raises(ArgumentError) { TimezonePeriod.new(start_t, end_t, special) } end def test_initialize_start std = TimezoneOffset.new(-7200, 0, :TEST) dst = TimezoneOffset.new(-7200, 3600, :TEST) start_t = TestTimezoneTransition.new(dst, std, 1136073600) p = TimezonePeriod.new(start_t, nil) assert_same(start_t, p.start_transition) assert_nil(p.end_transition) assert_same(dst, p.offset) assert_equal(DateTime.new(2006,1,1,0,0,0), p.utc_start) assert_equal(Time.utc(2006,1,1,0,0,0), p.utc_start_time) assert_nil(p.utc_end) assert_nil(p.utc_end_time) assert_equal(-7200, p.utc_offset) assert_equal(3600, p.std_offset) assert_equal(-3600, p.utc_total_offset) assert_equal(Rational(-3600, 86400), p.utc_total_offset_rational) assert_equal(:TEST, p.zone_identifier) assert_equal(:TEST, p.abbreviation) assert_equal(DateTime.new(2005,12,31,23,0,0), p.local_start) assert_equal(Time.utc(2005,12,31,23,0,0), p.local_start_time) assert_nil(p.local_end) assert_nil(p.local_end_time) end def test_initialize_start_offset std = TimezoneOffset.new(-7200, 0, :TEST) dst = TimezoneOffset.new(-7200, 3600, :TEST) special = TimezoneOffset.new(0, 0, :SPECIAL) start_t = TestTimezoneTransition.new(dst, std, 1136073600) assert_raises(ArgumentError) { TimezonePeriod.new(start_t, nil, special) } end def test_initialize_end std = TimezoneOffset.new(-7200, 0, :TEST) dst = TimezoneOffset.new(-7200, 3600, :TEST) end_t = TestTimezoneTransition.new(std, dst, 1136160000) p = TimezonePeriod.new(nil, end_t) assert_nil(p.start_transition) assert_same(end_t, p.end_transition) assert_same(dst, p.offset) assert_nil(p.utc_start) assert_nil(p.utc_start_time) assert_equal(DateTime.new(2006,1,2,0,0,0), p.utc_end) assert_equal(Time.utc(2006,1,2,0,0,0), p.utc_end_time) assert_equal(-7200, p.utc_offset) assert_equal(3600, p.std_offset) assert_equal(-3600, p.utc_total_offset) assert_equal(Rational(-3600, 86400), p.utc_total_offset_rational) assert_equal(:TEST, p.zone_identifier) assert_equal(:TEST, p.abbreviation) assert_nil(p.local_start) assert_nil(p.local_start_time) assert_equal(DateTime.new(2006,1,1,23,0,0), p.local_end) assert_equal(Time.utc(2006,1,1,23,0,0), p.local_end_time) end def test_initialize_end_offset std = TimezoneOffset.new(-7200, 0, :TEST) dst = TimezoneOffset.new(-7200, 3600, :TEST) special = TimezoneOffset.new(0, 0, :SPECIAL) end_t = TestTimezoneTransition.new(std, dst, 1136160000) assert_raises(ArgumentError) { TimezonePeriod.new(nil, end_t, special) } end def test_initialize assert_raises(ArgumentError) { TimezonePeriod.new(nil, nil) } end def test_initialize_offset special = TimezoneOffset.new(0, 0, :SPECIAL) p = TimezonePeriod.new(nil, nil, special) assert_nil(p.start_transition) assert_nil(p.end_transition) assert_same(special, p.offset) assert_nil(p.utc_start) assert_nil(p.utc_start_time) assert_nil(p.utc_end) assert_nil(p.utc_end_time) assert_equal(0, p.utc_offset) assert_equal(0, p.std_offset) assert_equal(0, p.utc_total_offset) assert_equal(Rational(0, 86400), p.utc_total_offset_rational) assert_equal(:SPECIAL, p.zone_identifier) assert_equal(:SPECIAL, p.abbreviation) assert_nil(p.local_start) assert_nil(p.local_start_time) assert_nil(p.local_end) assert_nil(p.local_end_time) end def test_dst p1 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 3600, :TEST)) p2 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 0, :TEST)) p3 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, -3600, :TEST)) p4 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 7200, :TEST)) p5 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, -7200, :TEST)) assert_equal(true, p1.dst?) assert_equal(false, p2.dst?) assert_equal(true, p3.dst?) assert_equal(true, p4.dst?) assert_equal(true, p5.dst?) end def test_valid_for_utc offset = TimezoneOffset.new(-7200, 3600, :TEST) t1 = TestTimezoneTransition.new(offset, offset, 1104541261) t2 = TestTimezoneTransition.new(offset, offset, 1107309722) t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 1, 1, 1, 1, 1)) t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 2, 2, 2, 2, 2)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(nil, t2) p3 = TimezonePeriod.new(t1, nil) p4 = TimezonePeriod.new(nil, nil, offset) p5 = TimezonePeriod.new(t3, t4) assert_equal(true, p1.valid_for_utc?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p1.valid_for_utc?(Time.utc(2005,2,2,2,2,1))) assert_equal(true, p1.valid_for_utc?(1104541262)) assert_equal(true, p1.valid_for_utc?(DateTime.new(2005,2,2,2,2,0))) assert_equal(false, p1.valid_for_utc?(DateTime.new(2005,1,1,1,1,0))) assert_equal(false, p1.valid_for_utc?(DateTime.new(2005,2,2,2,2,3))) assert_equal(false, p1.valid_for_utc?(DateTime.new(1960,1,1,1,1,0))) assert_equal(false, p1.valid_for_utc?(DateTime.new(2040,1,1,1,1,0))) assert_equal(true, p2.valid_for_utc?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p2.valid_for_utc?(Time.utc(2005,2,2,2,2,1))) assert_equal(true, p2.valid_for_utc?(1104541262)) assert_equal(true, p2.valid_for_utc?(DateTime.new(2005,2,2,2,2,0))) assert_equal(true, p2.valid_for_utc?(DateTime.new(2005,1,1,1,1,0))) assert_equal(false, p2.valid_for_utc?(DateTime.new(2005,2,2,2,2,3))) assert_equal(true, p2.valid_for_utc?(DateTime.new(1960,1,1,1,1,0))) assert_equal(false, p2.valid_for_utc?(DateTime.new(2040,1,1,1,1,0))) assert_equal(true, p3.valid_for_utc?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p3.valid_for_utc?(Time.utc(2005,2,2,2,2,1))) assert_equal(true, p3.valid_for_utc?(1104541262)) assert_equal(true, p3.valid_for_utc?(DateTime.new(2005,2,2,2,2,0))) assert_equal(false, p3.valid_for_utc?(DateTime.new(2005,1,1,1,1,0))) assert_equal(true, p3.valid_for_utc?(DateTime.new(2005,2,2,2,2,3))) assert_equal(false, p3.valid_for_utc?(DateTime.new(1960,1,1,1,1,0))) assert_equal(true, p3.valid_for_utc?(DateTime.new(2040,1,1,1,1,0))) assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p4.valid_for_utc?(Time.utc(2005,2,2,2,2,1))) assert_equal(true, p4.valid_for_utc?(1104541262)) assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,2,2,2,2,0))) assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,1,1,1,1,0))) assert_equal(true, p4.valid_for_utc?(DateTime.new(2005,2,2,2,2,3))) assert_equal(true, p4.valid_for_utc?(DateTime.new(1960,1,1,1,1,0))) assert_equal(true, p4.valid_for_utc?(DateTime.new(2040,1,1,1,1,0))) assert_equal(false, p5.valid_for_utc?(Time.utc(2005,1,1,1,1,1))) assert_equal(false, p5.valid_for_utc?(1104541262)) end def test_utc_after_start offset = TimezoneOffset.new(-7200, 3600, :TEST) t1 = TestTimezoneTransition.new(offset, offset, 1104541261) t2 = TestTimezoneTransition.new(offset, offset, 1107309722) t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1)) t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(nil, t2) p3 = TimezonePeriod.new(t3, t4) assert_equal(true, p1.utc_after_start?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p1.utc_after_start?(Time.utc(2005,1,1,1,1,2))) assert_equal(false, p1.utc_after_start?(1104541260)) assert_equal(true, p1.utc_after_start?(DateTime.new(2045,1,1,1,1,0))) assert_equal(false, p1.utc_after_start?(DateTime.new(1955,1,1,1,1,0))) assert_equal(true, p2.utc_after_start?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p2.utc_after_start?(Time.utc(2005,1,1,1,1,2))) assert_equal(true, p2.utc_after_start?(1104541260)) assert_equal(true, p3.utc_after_start?(Time.utc(2005,1,2,1,1,1))) assert_equal(true, p3.utc_after_start?(1104627661)) end def test_utc_before_end offset = TimezoneOffset.new(-7200, 3600, :TEST) t1 = TestTimezoneTransition.new(offset, offset, 1104541261) t2 = TestTimezoneTransition.new(offset, offset, 1107309722) t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1)) t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t1, nil) p3 = TimezonePeriod.new(t3, t4) assert_equal(true, p1.utc_before_end?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p1.utc_before_end?(Time.utc(2005,2,2,2,2,0))) assert_equal(false, p1.utc_before_end?(1107309723)) assert_equal(false, p1.utc_before_end?(DateTime.new(2045,1,1,1,1,0))) assert_equal(true, p1.utc_before_end?(DateTime.new(1955,1,1,1,1,0))) assert_equal(true, p2.utc_before_end?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p2.utc_before_end?(Time.utc(2005,2,2,2,2,0))) assert_equal(true, p2.utc_before_end?(1107309723)) assert_equal(false, p3.utc_before_end?(Time.utc(2005,1,2,1,1,1))) assert_equal(false, p3.utc_before_end?(1104627661)) end def test_valid_for_local offset = TimezoneOffset.new(-7200, 3600, :TEST) t1 = TestTimezoneTransition.new(offset, offset, 1104544861) t2 = TestTimezoneTransition.new(offset, offset, 1107313322) t3 = TestTimezoneTransition.new(offset, offset, 1104544861) t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 1, 1, 1, 1, 1)) t5 = TestTimezoneTransition.new(offset, offset, DateTime.new(1960, 2, 2, 2, 2, 2)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(nil, t2) p3 = TimezonePeriod.new(t3, nil) p4 = TimezonePeriod.new(nil, nil, offset) p5 = TimezonePeriod.new(t4, t5) assert_equal(true, p1.valid_for_local?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p1.valid_for_local?(Time.utc(2005,2,2,2,2,1))) assert_equal(true, p1.valid_for_local?(1104541262)) assert_equal(true, p1.valid_for_local?(DateTime.new(2005,2,2,2,2,0))) assert_equal(false, p1.valid_for_local?(DateTime.new(2005,1,1,1,1,0))) assert_equal(false, p1.valid_for_local?(DateTime.new(2005,2,2,2,2,3))) assert_equal(false, p1.valid_for_local?(DateTime.new(1960,1,1,1,1,0))) assert_equal(false, p1.valid_for_local?(DateTime.new(2040,1,1,1,1,0))) assert_equal(true, p2.valid_for_local?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p2.valid_for_local?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p2.valid_for_local?(1104541262)) assert_equal(true, p2.valid_for_local?(DateTime.new(2005,2,2,2,2,0))) assert_equal(true, p2.valid_for_local?(DateTime.new(2005,1,1,1,1,0))) assert_equal(false, p2.valid_for_local?(DateTime.new(2005,2,2,2,2,3))) assert_equal(true, p2.valid_for_local?(DateTime.new(1960,1,1,1,1,0))) assert_equal(false, p2.valid_for_local?(DateTime.new(2040,1,1,1,1,0))) assert_equal(true, p3.valid_for_local?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p3.valid_for_local?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p3.valid_for_local?(1104541262)) assert_equal(true, p3.valid_for_local?(DateTime.new(2005,2,2,2,2,0))) assert_equal(false, p3.valid_for_local?(DateTime.new(2005,1,1,1,1,0))) assert_equal(true, p3.valid_for_local?(DateTime.new(2005,2,2,2,2,3))) assert_equal(false, p3.valid_for_local?(DateTime.new(1960,1,1,1,1,0))) assert_equal(true, p3.valid_for_local?(DateTime.new(2040,1,1,1,1,0))) assert_equal(true, p4.valid_for_local?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p4.valid_for_local?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p4.valid_for_local?(1104541262)) assert_equal(true, p4.valid_for_local?(DateTime.new(2005,2,2,2,2,0))) assert_equal(true, p4.valid_for_local?(DateTime.new(2005,1,1,1,1,0))) assert_equal(true, p4.valid_for_local?(DateTime.new(2005,2,2,2,2,3))) assert_equal(true, p4.valid_for_local?(DateTime.new(1960,1,1,1,1,0))) assert_equal(true, p4.valid_for_local?(DateTime.new(2040,1,1,1,1,0))) assert_equal(false, p5.valid_for_utc?(Time.utc(2005,1,1,1,1,1))) assert_equal(false, p5.valid_for_utc?(1104541262)) end def test_local_after_start offset = TimezoneOffset.new(-7200, 3600, :TEST) t1 = TestTimezoneTransition.new(offset, offset, 1104544861) t2 = TestTimezoneTransition.new(offset, offset, 1107313322) t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1)) t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(nil, t2) p3 = TimezonePeriod.new(t3, t4) assert_equal(true, p1.local_after_start?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p1.local_after_start?(Time.utc(2005,1,1,1,1,2))) assert_equal(false, p1.local_after_start?(1104541260)) assert_equal(true, p1.local_after_start?(DateTime.new(2045,1,1,1,1,0))) assert_equal(false, p1.local_after_start?(DateTime.new(1955,1,1,1,1,0))) assert_equal(true, p2.local_after_start?(DateTime.new(2005,1,1,1,1,1))) assert_equal(true, p2.local_after_start?(Time.utc(2005,1,1,1,1,2))) assert_equal(true, p2.local_after_start?(1104541260)) assert_equal(true, p3.local_after_start?(Time.utc(2005,1,2,1,1,1))) assert_equal(true, p3.local_after_start?(1104627661)) end def test_local_before_end offset = TimezoneOffset.new(-7200, 3600, :TEST) t1 = TestTimezoneTransition.new(offset, offset, 1104544861) t2 = TestTimezoneTransition.new(offset, offset, 1107313322) t3 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 1, 1, 1, 1, 1)) t4 = TestTimezoneTransition.new(offset, offset, DateTime.new(1945, 2, 2, 2, 2, 2)) p1 = TimezonePeriod.new(t1, t2) p2 = TimezonePeriod.new(t1, nil) p3 = TimezonePeriod.new(t3, t4) assert_equal(true, p1.local_before_end?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p1.local_before_end?(Time.utc(2005,2,2,2,2,0))) assert_equal(false, p1.local_before_end?(1107309723)) assert_equal(false, p1.local_before_end?(DateTime.new(2045,1,1,1,1,0))) assert_equal(true, p1.local_before_end?(DateTime.new(1955,1,1,1,1,0))) assert_equal(true, p2.local_before_end?(DateTime.new(2005,2,2,2,2,1))) assert_equal(true, p2.local_before_end?(Time.utc(2005,2,2,2,2,0))) assert_equal(true, p2.local_before_end?(1107309723)) assert_equal(false, p3.local_before_end?(Time.utc(2005,1,2,1,1,1))) assert_equal(false, p3.local_before_end?(1104627661)) end def test_to_local p1 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 3600, :TEST)) p2 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 0, :TEST)) p3 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(7200, 3600, :TEST)) assert_equal(DateTime.new(2005,1,19,22,0,0), p1.to_local(DateTime.new(2005,1,20,1,0,0))) assert_equal(DateTime.new(2005,1,19,22,0,0 + Rational(512,1000)), p1.to_local(DateTime.new(2005,1,20,1,0,0 + Rational(512,1000)))) assert_equal(Time.utc(2005,1,19,21,0,0), p2.to_local(Time.utc(2005,1,20,1,0,0))) assert_equal(Time.utc(2005,1,19,21,0,0,512000), p2.to_local(Time.utc(2005,1,20,1,0,0,512000))) assert_equal(1106193600, p3.to_local(1106182800)) end def test_to_utc p1 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 3600, :TEST)) p2 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(-14400, 0, :TEST)) p3 = TimezonePeriod.new(nil, nil, TimezoneOffset.new(7200, 3600, :TEST)) assert_equal(DateTime.new(2005,1,20,4,0,0), p1.to_utc(DateTime.new(2005,1,20,1,0,0))) assert_equal(DateTime.new(2005,1,20,4,0,0 + Rational(571,1000)), p1.to_utc(DateTime.new(2005,1,20,1,0,0 + Rational(571,1000)))) assert_equal(Time.utc(2005,1,20,5,0,0), p2.to_utc(Time.utc(2005,1,20,1,0,0))) assert_equal(Time.utc(2005,1,20,5,0,0,571000), p2.to_utc(Time.utc(2005,1,20,1,0,0,571000))) assert_equal(1106172000, p3.to_utc(1106182800)) end def test_time_boundary_start o1 = TimezoneOffset.new(-3600, 0, :TEST) o2 = TimezoneOffset.new(-3600, 3600, :TEST) t1 = TestTimezoneTransition.new(o1, o2, 0) p1 = TimezonePeriod.new(t1, nil) assert_equal(DateTime.new(1969,12,31,23,0,0), p1.local_start) # Conversion to Time will fail on systems that don't support negative times. if RubyCoreSupport.time_supports_negative assert_equal(Time.utc(1969,12,31,23,0,0), p1.local_start_time) end end def test_time_boundary_end o1 = TimezoneOffset.new(0, 3600, :TEST) o2 = TimezoneOffset.new(0, 0, :TEST) t1 = TestTimezoneTransition.new(o2, o1, 2147482800) p1 = TimezonePeriod.new(nil, t1) assert_equal(DateTime.new(2038,1,19,4,0,0), p1.local_end) # Conversion to Time will fail on systems that don't support 64-bit times if RubyCoreSupport.time_supports_64bit assert_equal(Time.utc(2038,1,19,4,0,0), p1.local_end_time) end end def test_equality o1 = TimezoneOffset.new(0, 3600, :TEST) o2 = TimezoneOffset.new(0, 0, :TEST) t1 = TestTimezoneTransition.new(o1, o2, 1149368400) t2 = TestTimezoneTransition.new(o1, o2, DateTime.new(2006, 6, 3, 21, 0, 0)) t3 = TestTimezoneTransition.new(o1, o2, 1149454800) t4 = TestTimezoneTransition.new(o1, o2, 1149541200) p1 = TimezonePeriod.new(t1, t3) p2 = TimezonePeriod.new(t1, t3) p3 = TimezonePeriod.new(t2, t3) p4 = TimezonePeriod.new(t3, nil) p5 = TimezonePeriod.new(t3, nil) p6 = TimezonePeriod.new(t4, nil) p7 = TimezonePeriod.new(nil, t3) p8 = TimezonePeriod.new(nil, t3) p9 = TimezonePeriod.new(nil, t4) p10 = TimezonePeriod.new(nil, nil, o1) p11 = TimezonePeriod.new(nil, nil, o1) p12 = TimezonePeriod.new(nil, nil, o2) assert_equal(true, p1 == p1) assert_equal(true, p1 == p2) assert_equal(true, p1 == p3) assert_equal(false, p1 == p4) assert_equal(false, p1 == p5) assert_equal(false, p1 == p6) assert_equal(false, p1 == p7) assert_equal(false, p1 == p8) assert_equal(false, p1 == p9) assert_equal(false, p1 == p10) assert_equal(false, p1 == p11) assert_equal(false, p1 == p12) assert_equal(false, p1 == Object.new) assert_equal(true, p4 == p4) assert_equal(true, p4 == p5) assert_equal(false, p4 == p6) assert_equal(false, p4 == Object.new) assert_equal(true, p7 == p7) assert_equal(true, p7 == p8) assert_equal(false, p7 == p9) assert_equal(false, p7 == Object.new) assert_equal(true, p10 == p10) assert_equal(true, p10 == p11) assert_equal(false, p10 == p12) assert_equal(false, p10 == Object.new) end def test_eql o1 = TimezoneOffset.new(0, 3600, :TEST) o2 = TimezoneOffset.new(0, 0, :TEST) t1 = TestTimezoneTransition.new(o1, o2, 1149368400) t2 = TestTimezoneTransition.new(o1, o2, DateTime.new(2006, 6, 3, 21, 0, 0)) t3 = TestTimezoneTransition.new(o1, o2, 1149454800) t4 = TestTimezoneTransition.new(o1, o2, 1149541200) p1 = TimezonePeriod.new(t1, t3) p2 = TimezonePeriod.new(t1, t3) p3 = TimezonePeriod.new(t2, t3) p4 = TimezonePeriod.new(t3, nil) p5 = TimezonePeriod.new(t3, nil) p6 = TimezonePeriod.new(t4, nil) p7 = TimezonePeriod.new(nil, t3) p8 = TimezonePeriod.new(nil, t3) p9 = TimezonePeriod.new(nil, t4) p10 = TimezonePeriod.new(nil, nil, o1) p11 = TimezonePeriod.new(nil, nil, o1) p12 = TimezonePeriod.new(nil, nil, o2) assert_equal(true, p1.eql?(p1)) assert_equal(true, p1.eql?(p2)) assert_equal(false, p1.eql?(p3)) assert_equal(false, p1.eql?(p4)) assert_equal(false, p1.eql?(p5)) assert_equal(false, p1.eql?(p6)) assert_equal(false, p1.eql?(p7)) assert_equal(false, p1.eql?(p8)) assert_equal(false, p1.eql?(p9)) assert_equal(false, p1.eql?(p10)) assert_equal(false, p1.eql?(p11)) assert_equal(false, p1.eql?(p12)) assert_equal(false, p1.eql?(Object.new)) assert_equal(true, p4.eql?(p4)) assert_equal(true, p4.eql?(p5)) assert_equal(false, p4.eql?(p6)) assert_equal(false, p4.eql?(Object.new)) assert_equal(true, p7.eql?(p7)) assert_equal(true, p7.eql?(p8)) assert_equal(false, p7.eql?(p9)) assert_equal(false, p7.eql?(Object.new)) assert_equal(true, p10.eql?(p10)) assert_equal(true, p10.eql?(p11)) assert_equal(false, p10.eql?(p12)) assert_equal(false, p10.eql?(Object.new)) end def test_hash o1 = TimezoneOffset.new(0, 3600, :TEST) o2 = TimezoneOffset.new(0, 0, :TEST) t1 = TestTimezoneTransition.new(o1, o2, 1149368400) t2 = TestTimezoneTransition.new(o1, o2, DateTime.new(2006, 6, 3, 21, 0, 0)) t3 = TestTimezoneTransition.new(o1, o2, 1149454800) t4 = TestTimezoneTransition.new(o1, o2, 1149541200) p1 = TimezonePeriod.new(t1, t3) p2 = TimezonePeriod.new(t2, nil) p3 = TimezonePeriod.new(nil, t4) p4 = TimezonePeriod.new(nil, nil, o1) assert_equal(t1.hash ^ t3.hash, p1.hash) assert_equal(t2.hash ^ nil.hash, p2.hash) assert_equal(nil.hash ^ t4.hash, p3.hash) assert_equal(nil.hash ^ nil.hash ^ o1.hash, p4.hash) end end tzinfo-1.2.2/test/tc_country_index_definition.rb0000644000004100000410000000333012400401360022136 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCCountryIndexDefinition < Minitest::Test module CountriesTest1 include CountryIndexDefinition country 'ZZ', 'Country One' do |c| c.timezone 'Test/Zone/1', 3, 2, 41,20 end country 'AA', 'Aland' do |c| c.timezone 'Test/Zone/3', 71,30, 358, 15 c.timezone 'Test/Zone/2', 41, 20, 211, 30 end country 'TE', 'Three' end module CountriesTest2 include CountryIndexDefinition country 'CO', 'First Country' do |c| end end def test_module_1 hash = CountriesTest1.countries assert_equal(3, hash.length) assert_equal(true, hash.frozen?) zz = hash['ZZ'] aa = hash['AA'] te = hash['TE'] assert_kind_of(RubyCountryInfo, zz) assert_equal('ZZ', zz.code) assert_equal('Country One', zz.name) assert_equal(1, zz.zones.length) assert_equal('Test/Zone/1', zz.zones[0].identifier) assert_kind_of(RubyCountryInfo, aa) assert_equal('AA', aa.code) assert_equal('Aland', aa.name) assert_equal(2, aa.zones.length) assert_equal('Test/Zone/3', aa.zones[0].identifier) assert_equal('Test/Zone/2', aa.zones[1].identifier) assert_kind_of(RubyCountryInfo, te) assert_equal('TE', te.code) assert_equal('Three', te.name) assert_equal(0, te.zones.length) end def test_module_2 hash = CountriesTest2.countries assert_equal(1, hash.length) assert_equal(true, hash.frozen?) co = hash['CO'] assert_kind_of(RubyCountryInfo, co) assert_equal('CO', co.code) assert_equal('First Country', co.name) assert_equal(0, co.zones.length) end end tzinfo-1.2.2/test/zoneinfo/0000755000004100000410000000000012400401360015651 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/Europe/0000755000004100000410000000000012400401360017110 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/Europe/London0000644000004100000410000000714712400401360020275 0ustar www-datawww-dataTZif2& 0à ve {ȠN? %` ' *, Ӡ l N y0 РpLrP.IZ 02vXԠ W  x z Xy Q8[ : X֠ &ʗYw;ͱ`Xϐn^r2i c)I !BN . p  ޴߮ ̠rHkt R*T2 = ) T q S  g} aI_ Jf _A ! ?#  Ѡ {ǻpp )X P  : 0  l N  0  qޠ.Qy1X#8Ɛ͐㯐Ñk lr!M"LT#a/$,6%JK& '*-'4) )*+,Ӑ-ڐ./t00$1]2r3=4R562x688a9v:C;X<_=:>A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y  LMTBSTGMTBDSTTZif2] & 0à ve {ȠN? %` ' *, Ӡ l N y0 РpLrP.IZ 02vXԠ W  x z Xy Q8[ : X֠ &ʗYw;ͱ`Xϐn^r2i c)I !BN . p  ޴߮ ̠rHkt R*T2 = ) T q S  g} aI_ Jf _A ! ?#  Ѡ {ǻpp )X P  : 0  l N  0  qޠ.Qy1X#8Ɛ͐㯐Ñk lr!M"LT#a/$,6%JK& '*-'4) )*+,Ӑ-ڐ./t00$1]2r3=4R562x688a9v:C;X<_=:>A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y  LMTBSTGMTBDST GMT0BST,M3.5.0/1,M10.5.0 tzinfo-1.2.2/test/zoneinfo/Europe/Andorra0000644000004100000410000000332712400401360020426 0ustar www-datawww-dataTZif2lA| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~yl  LMTWETCETCESTTZif2m~6A| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~yl  LMTWETCETCEST CET-1CEST,M3.5.0,M10.5.0/3 tzinfo-1.2.2/test/zoneinfo/Europe/Amsterdam0000644000004100000410000000557712400401360020766 0ustar www-datawww-dataTZif2 .\ٸ %  Av p#V P6 %['^㌩Z 煌' gf IΙ+pH R P* s0 T  @x q쌼 Ό،]x§ˌ]\Xtpp8Vp`!rDPKͩ΢Cϒ4Ђ%rN@ *p cEt6d'TMD3#ܐ͐㯐ӠÑ| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y         LMTNSTAMTNETNESTCETCESTTZif2Ql .\ٸ %  Av p#V P6 %['^Z 煌' gf IΙ+pH R P* s0 T  @x q Ό،]x§ˌ]\Xtpp8Vp`!rDPKͩ΢Cϒ4Ђ%rN@ *p cEt6d'TMD3#ܐ͐㯐ӠÑ| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y         LMTNSTAMTNETNESTCETCEST CET-1CEST,M3.5.0,M10.5.0/3 tzinfo-1.2.2/test/zoneinfo/Europe/Prague0000644000004100000410000000434012400401360020257 0ustar www-datawww-dataTZif2 `ٮ qKͩ΢Cϒ4n^yҡOӀIL8), pxdpd'TMD3#ܐ͐㯐ӠÑ| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y       PMTCESTCETTZif2Il `ٮ qKͩ΢Cϒ4n^yҡOӀIL8), pxdpd'TMD3#ܐ͐㯐ӠÑ| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y       LMTPMTCESTCET CET-1CEST,M3.5.0,M10.5.0/3 tzinfo-1.2.2/test/zoneinfo/Europe/Paris0000644000004100000410000000563312400401360020120 0ustar www-datawww-dataTZif2 `PGx,ppHp*` .zL5^#p%5'X&p}4p_PAɧ#Opkp"prpPpI//p2Lpppp`ȷ𽸨_pxlh]XN?p80:Xp l'Kͩ΢Cϒ4OЉrN@ 9  cEt6d'TMD3#ܐ͐㯐ӠÑ| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y   11      LMTPMTWESTWETCETCESTWEMTTZif2 kJ`PGx,ppHp*` .zL5^#p%5'X&p}4p_PAɧ#Opkp"prpPpI//p2Lpppp`ȷ_pxlh]XN?p80:Xp l'Kͩ΢Cϒ4OЉrN@ 9  cEt6d'TMD3#ܐ͐㯐ӠÑ| lr!\c"LT#A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y   11      LMTPMTWESTWETCETCESTWEMT CET-1CEST,M3.5.0,M10.5.0/3 tzinfo-1.2.2/test/zoneinfo/posixrules0000644000004100000410000000673112400401360020020 0ustar www-datawww-dataTZif2p`p`epjp5`S`3އpiRK௳4~-౜QpgJ`|3pG,`\p'`;p`p`ƴ`Ĺ𿏲o„}Ovd_/XM|p:-^pW` @p9`ˈp#p`u@U 5peމpݩ`޾kp߉d`MpiF`~/pI(`^pW.G-7'ֶƵ`p`p`op_y`Oxp?[`/Zp(wp?b@opA`BOpCda`D/vpEDC`EG-_GӊI AIlJ#KpL@`M|kpN"`O\MpP`Qp?b@opA`BOpCda`D/vpEDC`EG-_GӊI AIlJ#KpL@`M|kpN"`O\MpP`QxXf8H矀!dǁFc(E y Y~!w"B#i$"}%I&_')') )*s+ʀ,ҏ-x.q/t>0S1]Z2r53=<4R5616889:Ā;<=>?@eABECcD.EC~FKG#`GHIׄJuKfLWMHN9Ow*PpUQ`FRP7S@(T0U VVW݀X΀YϿZ[\]^_x`haXbHsc8dd(UeFfqgbgShDi5j&klmnopۀpjqYrIs9t)uv vwxـyqzb{|~}o~`rQ  LMTAEDTAESTTZif2sN TWp̷Vͧ9pΠsχpp9 P8/ ߀  ~^>xXf8H矀!dǁFc(E y Y~!w"B#i$"}%I&_')') )*s+ʀ,ҏ-x.q/t>0S1]Z2r53=<4R5616889:Ā;<=>?@eABECcD.EC~FKG#`GHIׄJuKfLWMHN9Ow*PpUQ`FRP7S@(T0U VVW݀X΀YϿZ[\]^_x`haXbHsc8dd(UeFfqgbgShDi5j&klmnopۀpjqYrIs9t)uv vwxـyqzb{|~}o~`rQ  LMTAEDTAEST AEST-10AEDT,M10.1.0,M4.1.0/3 tzinfo-1.2.2/test/zoneinfo/America/0000755000004100000410000000000012400401360017212 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/America/Argentina/0000755000004100000410000000000012400401360021122 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/America/Argentina/Buenos_Aires0000644000004100000410000000207712400401360023431 0ustar www-datawww-dataTZif2=0{R@ɰ@p0}@0x @Z@;0~`@*0A70ȁ@MM0ΰ)5Cd=0l02@柰C0w@65S0R@504@J$o#$%7%v'!0'X)0):*0+W 7ư8*Gw G HIa 4  LMTCMTARTARSTTZif2>rL0{R@ɰ@p0}@0x @Z@;0~`@*0A70ȁ@MM0ΰ)5Cd=0l02@柰C0w@65S0R@504@J$o#$%7%v'!0'X)0):*0+W 7ư8*Gw G HIa 4  LMTCMTARTARST ART3 tzinfo-1.2.2/test/zoneinfo/America/New_York0000644000004100000410000000673112400401360020701 0ustar www-datawww-dataTZif2p`p`epjp5`S`3އpiRK௳4~-౜QpgJ`|3pG,`\p'`;p`p`ƴ`Ĺ𿏲o„}Ovd_/XM|p:-^pW` @p9`ˈp#p`u@U 5peމpݩ`޾kp߉d`MpiF`~/pI(`^pW.G-7'ֶƵ`p`p`op_y`Oxp?[`/Zp(wp?b@opA`BOpCda`D/vpEDC`EG-_GӊI AIlJ#KpL@`M|kpN"`O\MpP`Qp?b@opA`BOpCda`D/vpEDC`EG-_GӊI AIlJ#KpL@`M|kpN"`O\MpP`QA?@f#A9&BFCd&D%EC'FɧG#'G'I'I(J(K(L̿M(NOnn(PQWRleS7lTLGUNV,)V0XF)XY()Z[ )\)])^)_)`_)a}b?)c]̩d)e=fgg藩hriyjTk[lq)m=nS)ohp5)qQ<)rf)s1)tE)u)v/v)xx)y٩z){λ|©}~y  LMTBSTGMTBDSTX gS H +  ?rΦ ʉ  b1 % ! %'*P,2).\0$3H6CI\OTZif2] & 0à ve {ȠN? %` ' *, Ӡ l N y0 РpLrP.IZ 02vXԠ W  x z Xy Q8[ : X֠ &ʗYw;ͱ`Xϐn^r2i c)I !BN . p  ޴߮ ̠rHkt R*T2 = ) T q S  g} aI_ Jf _A ! ?#  Ѡ {ǻpp )X P! :"0"# l# $ N$  0% &qާ.Qy1X#8ƚ͚㯛Ñk lr!M"LT#a/$,6%JK& '*-'4) )*+,Ӣ-ڢ./t00$1]$2r$3=$4R%5%62x%6&88a&9v:C&;X<_=:>A?@f#A9&BFCd&D%EC'FɧG#'G'I'I(J(K(L̿M(NOnn(PQWRleS7lTLGUNV,)V0XF)XY()Z[ )\)])^)_)`_)a}b?)c]̩d)e=fgg藩hriyjTk[lq)m=nS)ohp5)qQ<)rf)s1)tE)u)v/v)xx)y٩z){λ|©}~y  LMTBSTGMTBDSTX gS H +  ?rΦ ʉ  b1 % ! %'*P,2).\0$3H6CI\O GMT0BST,M3.5.0/1,M10.5.0 tzinfo-1.2.2/test/zoneinfo/iso3166.tab0000644000004100000410000001071212400401360017454 0ustar www-datawww-data# ISO 3166 alpha-2 country codes # # This file is in the public domain, so clarified as of # 2009-05-17 by Arthur David Olson. # # From Paul Eggert (2014-07-18): # This file contains a table of two-letter country codes. Columns are # separated by a single tab. Lines beginning with '#' are comments. # Although all text currently uses ASCII encoding, this is planned to # change to UTF-8 soon. The columns of the table are as follows: # # 1. ISO 3166-1 alpha-2 country code, current as of # ISO 3166-1 Newsletter VI-16 (2013-07-11). See: Updates on ISO 3166 # http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm # 2. The usual English name for the coded region, # chosen so that alphabetic sorting of subsets produces helpful lists. # This is not the same as the English name in the ISO 3166 tables. # # The table is sorted by country code. # # This table is intended as an aid for users, to help them select time # zone data appropriate for their practical needs. It is not intended # to take or endorse any position on legal or territorial claims. # #country- #code name of country, territory, area, or subdivision AD Andorra AE United Arab Emirates AF Afghanistan AG Antigua & Barbuda AI Anguilla AL Albania AM Armenia AO Angola AQ Antarctica AR Argentina AS Samoa (American) AT Austria AU Australia AW Aruba AX Aaland Islands AZ Azerbaijan BA Bosnia & Herzegovina BB Barbados BD Bangladesh BE Belgium BF Burkina Faso BG Bulgaria BH Bahrain BI Burundi BJ Benin BL St Barthelemy BM Bermuda BN Brunei BO Bolivia BQ Caribbean Netherlands BR Brazil BS Bahamas BT Bhutan BV Bouvet Island BW Botswana BY Belarus BZ Belize CA Canada CC Cocos (Keeling) Islands CD Congo (Dem. Rep.) CF Central African Rep. CG Congo (Rep.) CH Switzerland CI Cote d'Ivoire CK Cook Islands CL Chile CM Cameroon CN China CO Colombia CR Costa Rica CU Cuba CV Cape Verde CW Curacao CX Christmas Island CY Cyprus CZ Czech Republic DE Germany DJ Djibouti DK Denmark DM Dominica DO Dominican Republic DZ Algeria EC Ecuador EE Estonia EG Egypt EH Western Sahara ER Eritrea ES Spain ET Ethiopia FI Finland FJ Fiji FK Falkland Islands FM Micronesia FO Faroe Islands FR France GA Gabon GB Britain (UK) GD Grenada GE Georgia GF French Guiana GG Guernsey GH Ghana GI Gibraltar GL Greenland GM Gambia GN Guinea GP Guadeloupe GQ Equatorial Guinea GR Greece GS South Georgia & the South Sandwich Islands GT Guatemala GU Guam GW Guinea-Bissau GY Guyana HK Hong Kong HM Heard Island & McDonald Islands HN Honduras HR Croatia HT Haiti HU Hungary ID Indonesia IE Ireland IL Israel IM Isle of Man IN India IO British Indian Ocean Territory IQ Iraq IR Iran IS Iceland IT Italy JE Jersey JM Jamaica JO Jordan JP Japan KE Kenya KG Kyrgyzstan KH Cambodia KI Kiribati KM Comoros KN St Kitts & Nevis KP Korea (North) KR Korea (South) KW Kuwait KY Cayman Islands KZ Kazakhstan LA Laos LB Lebanon LC St Lucia LI Liechtenstein LK Sri Lanka LR Liberia LS Lesotho LT Lithuania LU Luxembourg LV Latvia LY Libya MA Morocco MC Monaco MD Moldova ME Montenegro MF St Martin (French part) MG Madagascar MH Marshall Islands MK Macedonia ML Mali MM Myanmar (Burma) MN Mongolia MO Macau MP Northern Mariana Islands MQ Martinique MR Mauritania MS Montserrat MT Malta MU Mauritius MV Maldives MW Malawi MX Mexico MY Malaysia MZ Mozambique NA Namibia NC New Caledonia NE Niger NF Norfolk Island NG Nigeria NI Nicaragua NL Netherlands NO Norway NP Nepal NR Nauru NU Niue NZ New Zealand OM Oman PA Panama PE Peru PF French Polynesia PG Papua New Guinea PH Philippines PK Pakistan PL Poland PM St Pierre & Miquelon PN Pitcairn PR Puerto Rico PS Palestine PT Portugal PW Palau PY Paraguay QA Qatar RE Reunion RO Romania RS Serbia RU Russia RW Rwanda SA Saudi Arabia SB Solomon Islands SC Seychelles SD Sudan SE Sweden SG Singapore SH St Helena SI Slovenia SJ Svalbard & Jan Mayen SK Slovakia SL Sierra Leone SM San Marino SN Senegal SO Somalia SR Suriname SS South Sudan ST Sao Tome & Principe SV El Salvador SX St Maarten (Dutch part) SY Syria SZ Swaziland TC Turks & Caicos Is TD Chad TF French Southern & Antarctic Lands TG Togo TH Thailand TJ Tajikistan TK Tokelau TL East Timor TM Turkmenistan TN Tunisia TO Tonga TR Turkey TT Trinidad & Tobago TV Tuvalu TW Taiwan TZ Tanzania UA Ukraine UG Uganda UM US minor outlying islands US United States UY Uruguay UZ Uzbekistan VA Vatican City VC St Vincent VE Venezuela VG Virgin Islands (UK) VI Virgin Islands (US) VN Vietnam VU Vanuatu WF Wallis & Futuna WS Samoa (western) YE Yemen YT Mayotte ZA South Africa ZM Zambia ZW Zimbabwe tzinfo-1.2.2/test/zoneinfo/EST0000644000004100000410000000017712400401360016234 0ustar www-datawww-dataTZif2ESTTZif2EST EST5 tzinfo-1.2.2/test/zoneinfo/Etc/0000755000004100000410000000000012400401360016364 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/Etc/UTC0000644000004100000410000000017712400401360016747 0ustar www-datawww-dataTZif2UTCTZif2UTC UTC0 tzinfo-1.2.2/test/zoneinfo/Factory0000644000004100000410000000041012400401360017176 0ustar www-datawww-dataTZif21Local time zone must be set--see zic manual pageTZif21Local time zone must be set--see zic manual page 0 tzinfo-1.2.2/test/zoneinfo/posix/0000755000004100000410000000000012400401360017013 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/posix/Europe/0000755000004100000410000000000012400401360020252 5ustar www-datawww-datatzinfo-1.2.2/test/zoneinfo/posix/Europe/London0000644000004100000410000000714712400401360021437 0ustar www-datawww-dataTZif2& 0à ve {ȠN? %` ' *, Ӡ l N y0 РpLrP.IZ 02vXԠ W  x z Xy Q8[ : X֠ &ʗYw;ͱ`Xϐn^r2i c)I !BN . p  ޴߮ ̠rHkt R*T2 = ) T q S  g} aI_ Jf _A ! ?#  Ѡ {ǻpp )X P  : 0  l N  0  qޠ.Qy1X#8Ɛ͐㯐Ñk lr!M"LT#a/$,6%JK& '*-'4) )*+,Ӑ-ڐ./t00$1]2r3=4R562x688a9v:C;X<_=:>A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y  LMTBSTGMTBDSTTZif2] & 0à ve {ȠN? %` ' *, Ӡ l N y0 РpLrP.IZ 02vXԠ W  x z Xy Q8[ : X֠ &ʗYw;ͱ`Xϐn^r2i c)I !BN . p  ޴߮ ̠rHkt R*T2 = ) T q S  g} aI_ Jf _A ! ?#  Ѡ {ǻpp )X P  : 0  l N  0  qޠ.Qy1X#8Ɛ͐㯐Ñk lr!M"LT#a/$,6%JK& '*-'4) )*+,Ӑ-ڐ./t00$1]2r3=4R562x688a9v:C;X<_=:>A?@f#A9BFCdD%ECFɐG#GIIJKL̿MNOnnPQWRleS7lTLGUNV,)V0XFXY(Z[ \]^_`_a}b?c]̐de=fgg藐hriyjTk[lqm=nSohp5qQ<rfs1tEuv/vxxyِz{λ|}~y  LMTBSTGMTBDST GMT0BST,M3.5.0/1,M10.5.0 tzinfo-1.2.2/test/zoneinfo/zone1970.tab0000644000004100000410000004411012400401360017635 0ustar www-datawww-data# tz zone descriptions # # This file is in the public domain. # # From Paul Eggert (2014-07-31): # This file contains a table where each row stands for a zone where # civil time stamps have agreed since 1970. Columns are separated by # a single tab. Lines beginning with '#' are comments. All text uses # UTF-8 encoding. The columns of the table are as follows: # # 1. The countries that overlap the zone, as a comma-separated list # of ISO 3166 2-character country codes. See the file 'iso3166.tab'. # 2. Latitude and longitude of the zone's principal location # in ISO 6709 sign-degrees-minutes-seconds format, # either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS, # first latitude (+ is north), then longitude (+ is east). # 3. Zone name used in value of TZ environment variable. # Please see the 'Theory' file for how zone names are chosen. # If multiple zones overlap a country, each has a row in the # table, with each column 1 containing the country code. # 4. Comments; present if and only if a country has multiple zones. # # If a zone covers multiple countries, the most-populous city is used, # and that country is listed first in column 1; any other countries # are listed alphabetically by country code. The table is sorted # first by country code, then (if possible) by an order within the # country that (1) makes some geographical sense, and (2) puts the # most populous zones first, where that does not contradict (1). # # This table is intended as an aid for users, to help them select time # zone data appropriate for their practical needs. It is not intended # to take or endorse any position on legal or territorial claims. # #country- #codes coordinates TZ comments AD +4230+00131 Europe/Andorra AE,OM +2518+05518 Asia/Dubai AF +3431+06912 Asia/Kabul AL +4120+01950 Europe/Tirane AM +4011+04430 Asia/Yerevan AQ -6734-06808 Antarctica/Rothera Rothera Station, Adelaide Island AQ -6448-06406 Antarctica/Palmer Palmer Station, Anvers Island AQ -6736+06253 Antarctica/Mawson Mawson Station, Holme Bay AQ -6835+07758 Antarctica/Davis Davis Station, Vestfold Hills AQ -6617+11031 Antarctica/Casey Casey Station, Bailey Peninsula AQ -7824+10654 Antarctica/Vostok Vostok Station, Lake Vostok AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I AQ -720041+0023206 Antarctica/Troll Troll Station, Queen Maud Land AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF) AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, MN, SE, SF) AR -2447-06525 America/Argentina/Salta (SA, LP, NQ, RN) AR -2411-06518 America/Argentina/Jujuy Jujuy (JY) AR -2649-06513 America/Argentina/Tucuman Tucumán (TM) AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH) AR -2926-06651 America/Argentina/La_Rioja La Rioja (LR) AR -3132-06831 America/Argentina/San_Juan San Juan (SJ) AR -3253-06849 America/Argentina/Mendoza Mendoza (MZ) AR -3319-06621 America/Argentina/San_Luis San Luis (SL) AR -5138-06913 America/Argentina/Rio_Gallegos Santa Cruz (SC) AR -5448-06818 America/Argentina/Ushuaia Tierra del Fuego (TF) AS,UM -1416-17042 Pacific/Pago_Pago Samoa, Midway AT +4813+01620 Europe/Vienna AU -3133+15905 Australia/Lord_Howe Lord Howe Island AU -5430+15857 Antarctica/Macquarie Macquarie Island AU -4253+14719 Australia/Hobart Tasmania - most locations AU -3956+14352 Australia/Currie Tasmania - King Island AU -3749+14458 Australia/Melbourne Victoria AU -3352+15113 Australia/Sydney New South Wales - most locations AU -3157+14127 Australia/Broken_Hill New South Wales - Yancowinna AU -2728+15302 Australia/Brisbane Queensland - most locations AU -2016+14900 Australia/Lindeman Queensland - Holiday Islands AU -3455+13835 Australia/Adelaide South Australia AU -1228+13050 Australia/Darwin Northern Territory AU -3157+11551 Australia/Perth Western Australia - most locations AU -3143+12852 Australia/Eucla Western Australia - Eucla area AZ +4023+04951 Asia/Baku BB +1306-05937 America/Barbados BD +2343+09025 Asia/Dhaka BE +5050+00420 Europe/Brussels BG +4241+02319 Europe/Sofia BM +3217-06446 Atlantic/Bermuda BN +0456+11455 Asia/Brunei BO -1630-06809 America/La_Paz BR -0351-03225 America/Noronha Atlantic islands BR -0127-04829 America/Belem Amapá, E Pará BR -0343-03830 America/Fortaleza NE Brazil (MA, PI, CE, RN, PB) BR -0803-03454 America/Recife Pernambuco BR -0712-04812 America/Araguaina Tocantins BR -0940-03543 America/Maceio Alagoas, Sergipe BR -1259-03831 America/Bahia Bahia BR -2332-04637 America/Sao_Paulo S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS) BR -2027-05437 America/Campo_Grande Mato Grosso do Sul BR -1535-05605 America/Cuiaba Mato Grosso BR -0226-05452 America/Santarem W Pará BR -0846-06354 America/Porto_Velho Rondônia BR +0249-06040 America/Boa_Vista Roraima BR -0308-06001 America/Manaus E Amazonas BR -0640-06952 America/Eirunepe W Amazonas BR -0958-06748 America/Rio_Branco Acre BS +2505-07721 America/Nassau BT +2728+08939 Asia/Thimphu BY +5354+02734 Europe/Minsk BZ +1730-08812 America/Belize CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador CA +4439-06336 America/Halifax Atlantic Time - Nova Scotia (most places), PEI CA +4612-05957 America/Glace_Bay Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971 CA +4606-06447 America/Moncton Atlantic Time - New Brunswick CA +5320-06025 America/Goose_Bay Atlantic Time - Labrador - most locations CA +5125-05707 America/Blanc-Sablon Atlantic Standard Time - Quebec - Lower North Shore CA +4339-07923 America/Toronto Eastern Time - Ontario & Quebec - most locations CA +4901-08816 America/Nipigon Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973 CA +4823-08915 America/Thunder_Bay Eastern Time - Thunder Bay, Ontario CA +6344-06828 America/Iqaluit Eastern Time - east Nunavut - most locations CA +6608-06544 America/Pangnirtung Eastern Time - Pangnirtung, Nunavut CA +744144-0944945 America/Resolute Central Time - Resolute, Nunavut CA +484531-0913718 America/Atikokan Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut CA +624900-0920459 America/Rankin_Inlet Central Time - central Nunavut CA +4953-09709 America/Winnipeg Central Time - Manitoba & west Ontario CA +4843-09434 America/Rainy_River Central Time - Rainy River & Fort Frances, Ontario CA +5024-10439 America/Regina Central Standard Time - Saskatchewan - most locations CA +5017-10750 America/Swift_Current Central Standard Time - Saskatchewan - midwest CA +5333-11328 America/Edmonton Mountain Time - Alberta, east British Columbia & west Saskatchewan CA +690650-1050310 America/Cambridge_Bay Mountain Time - west Nunavut CA +6227-11421 America/Yellowknife Mountain Time - central Northwest Territories CA +682059-1334300 America/Inuvik Mountain Time - west Northwest Territories CA +4906-11631 America/Creston Mountain Standard Time - Creston, British Columbia CA +5946-12014 America/Dawson_Creek Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia CA +4916-12307 America/Vancouver Pacific Time - west British Columbia CA +6043-13503 America/Whitehorse Pacific Time - south Yukon CA +6404-13925 America/Dawson Pacific Time - north Yukon CC -1210+09655 Indian/Cocos CH,DE,LI +4723+00832 Europe/Zurich Swiss time CI,BF,GM,GN,ML,MR,SH,SL,SN,ST,TG +0519-00402 Africa/Abidjan CK -2114-15946 Pacific/Rarotonga CL -3327-07040 America/Santiago most locations CL -2709-10926 Pacific/Easter Easter Island CN +3114+12128 Asia/Shanghai Beijing Time CN +4348+08735 Asia/Urumqi Xinjiang Time CO +0436-07405 America/Bogota CR +0956-08405 America/Costa_Rica CU +2308-08222 America/Havana CV +1455-02331 Atlantic/Cape_Verde CW,AW,BQ,SX +1211-06900 America/Curacao CX -1025+10543 Indian/Christmas CY +3510+03322 Asia/Nicosia CZ,SK +5005+01426 Europe/Prague DE +5230+01322 Europe/Berlin Berlin time DK +5540+01235 Europe/Copenhagen DO +1828-06954 America/Santo_Domingo DZ +3647+00303 Africa/Algiers EC -0210-07950 America/Guayaquil mainland EC -0054-08936 Pacific/Galapagos Galápagos Islands EE +5925+02445 Europe/Tallinn EG +3003+03115 Africa/Cairo EH +2709-01312 Africa/El_Aaiun ES +4024-00341 Europe/Madrid mainland ES +3553-00519 Africa/Ceuta Ceuta & Melilla ES +2806-01524 Atlantic/Canary Canary Islands FI,AX +6010+02458 Europe/Helsinki FJ -1808+17825 Pacific/Fiji FK -5142-05751 Atlantic/Stanley FM +0725+15147 Pacific/Chuuk Chuuk (Truk) and Yap FM +0658+15813 Pacific/Pohnpei Pohnpei (Ponape) FM +0519+16259 Pacific/Kosrae Kosrae FO +6201-00646 Atlantic/Faroe FR +4852+00220 Europe/Paris GB,GG,IM,JE +513030-0000731 Europe/London GE +4143+04449 Asia/Tbilisi GF +0456-05220 America/Cayenne GH +0533-00013 Africa/Accra GI +3608-00521 Europe/Gibraltar GL +6411-05144 America/Godthab most locations GL +7646-01840 America/Danmarkshavn east coast, north of Scoresbysund GL +7029-02158 America/Scoresbysund Scoresbysund / Ittoqqortoormiit GL +7634-06847 America/Thule Thule / Pituffik GR +3758+02343 Europe/Athens GS -5416-03632 Atlantic/South_Georgia GT +1438-09031 America/Guatemala GU,MP +1328+14445 Pacific/Guam GW +1151-01535 Africa/Bissau GY +0648-05810 America/Guyana HK +2217+11409 Asia/Hong_Kong HN +1406-08713 America/Tegucigalpa HT +1832-07220 America/Port-au-Prince HU +4730+01905 Europe/Budapest ID -0610+10648 Asia/Jakarta Java & Sumatra ID -0002+10920 Asia/Pontianak west & central Borneo ID -0507+11924 Asia/Makassar east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor ID -0232+14042 Asia/Jayapura west New Guinea (Irian Jaya) & Malukus (Moluccas) IE +5320-00615 Europe/Dublin IL +314650+0351326 Asia/Jerusalem IN +2232+08822 Asia/Kolkata IO -0720+07225 Indian/Chagos IQ +3321+04425 Asia/Baghdad IR +3540+05126 Asia/Tehran IS +6409-02151 Atlantic/Reykjavik IT,SM,VA +4154+01229 Europe/Rome JM +175805-0764736 America/Jamaica JO +3157+03556 Asia/Amman JP +353916+1394441 Asia/Tokyo KE,DJ,ER,ET,KM,MG,SO,TZ,UG,YT -0117+03649 Africa/Nairobi KG +4254+07436 Asia/Bishkek KI +0125+17300 Pacific/Tarawa Gilbert Islands KI -0308-17105 Pacific/Enderbury Phoenix Islands KI +0152-15720 Pacific/Kiritimati Line Islands KP +3901+12545 Asia/Pyongyang KR +3733+12658 Asia/Seoul KZ +4315+07657 Asia/Almaty most locations KZ +4448+06528 Asia/Qyzylorda Qyzylorda (Kyzylorda, Kzyl-Orda) KZ +5017+05710 Asia/Aqtobe Aqtobe (Aktobe) KZ +4431+05016 Asia/Aqtau Atyrau (Atirau, Gur'yev), Mangghystau (Mankistau) KZ +5113+05121 Asia/Oral West Kazakhstan LB +3353+03530 Asia/Beirut LK +0656+07951 Asia/Colombo LR +0618-01047 Africa/Monrovia LT +5441+02519 Europe/Vilnius LU +4936+00609 Europe/Luxembourg LV +5657+02406 Europe/Riga LY +3254+01311 Africa/Tripoli MA +3339-00735 Africa/Casablanca MC +4342+00723 Europe/Monaco MD +4700+02850 Europe/Chisinau MH +0709+17112 Pacific/Majuro most locations MH +0905+16720 Pacific/Kwajalein Kwajalein MM +1647+09610 Asia/Rangoon MN +4755+10653 Asia/Ulaanbaatar most locations MN +4801+09139 Asia/Hovd Bayan-Ölgii, Govi-Altai, Hovd, Uvs, Zavkhan MN +4804+11430 Asia/Choibalsan Dornod, Sükhbaatar MO +2214+11335 Asia/Macau MQ +1436-06105 America/Martinique MT +3554+01431 Europe/Malta MU -2010+05730 Indian/Mauritius MV +0410+07330 Indian/Maldives MX +1924-09909 America/Mexico_City Central Time - most locations MX +2105-08646 America/Cancun Central Time - Quintana Roo MX +2058-08937 America/Merida Central Time - Campeche, Yucatán MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo León, Tamaulipas away from US border MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo León, Tamaulipas near US border MX +2313-10625 America/Mazatlan Mountain Time - S Baja, Nayarit, Sinaloa MX +2838-10605 America/Chihuahua Mexican Mountain Time - Chihuahua away from US border MX +2934-10425 America/Ojinaga US Mountain Time - Chihuahua near US border MX +2904-11058 America/Hermosillo Mountain Standard Time - Sonora MX +3232-11701 America/Tijuana US Pacific Time - Baja California near US border MX +3018-11452 America/Santa_Isabel Mexican Pacific Time - Baja California away from US border MX +2048-10515 America/Bahia_Banderas Mexican Central Time - Bahía de Banderas MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia MY +0133+11020 Asia/Kuching Sabah & Sarawak MZ,BI,BW,CD,MW,RW,ZM,ZW -2558+03235 Africa/Maputo Central Africa Time (UTC+2) NA -2234+01706 Africa/Windhoek NC -2216+16627 Pacific/Noumea NF -2903+16758 Pacific/Norfolk NG,AO,BJ,CD,CF,CG,CM,GA,GQ,NE +0627+00324 Africa/Lagos West Africa Time (UTC+1) NI +1209-08617 America/Managua NL +5222+00454 Europe/Amsterdam NO,SJ +5955+01045 Europe/Oslo NP +2743+08519 Asia/Kathmandu NR -0031+16655 Pacific/Nauru NU -1901-16955 Pacific/Niue NZ,AQ -3652+17446 Pacific/Auckland New Zealand time NZ -4357-17633 Pacific/Chatham Chatham Islands PA,KY +0858-07932 America/Panama PE -1203-07703 America/Lima PF -1732-14934 Pacific/Tahiti Society Islands PF -0900-13930 Pacific/Marquesas Marquesas Islands PF -2308-13457 Pacific/Gambier Gambier Islands PG -0930+14710 Pacific/Port_Moresby PH +1435+12100 Asia/Manila PK +2452+06703 Asia/Karachi PL +5215+02100 Europe/Warsaw PM +4703-05620 America/Miquelon PN -2504-13005 Pacific/Pitcairn PR +182806-0660622 America/Puerto_Rico PS +3130+03428 Asia/Gaza Gaza Strip PS +313200+0350542 Asia/Hebron West Bank PT +3843-00908 Europe/Lisbon mainland PT +3238-01654 Atlantic/Madeira Madeira Islands PT +3744-02540 Atlantic/Azores Azores PW +0720+13429 Pacific/Palau PY -2516-05740 America/Asuncion QA,BH +2517+05132 Asia/Qatar RE,TF -2052+05528 Indian/Reunion Réunion, Crozet Is, Scattered Is RO +4426+02606 Europe/Bucharest RS,BA,HR,ME,MK,SI +4450+02030 Europe/Belgrade RU +5443+02030 Europe/Kaliningrad Moscow-01 - Kaliningrad RU +554521+0373704 Europe/Moscow Moscow+00 - west Russia RU +4457+03406 Europe/Simferopol Moscow+00 - Crimea RU +4844+04425 Europe/Volgograd Moscow+00 - Caspian Sea RU +5312+05009 Europe/Samara Moscow+00 (Moscow+01 after 2014-10-26) - Samara, Udmurtia RU +5651+06036 Asia/Yekaterinburg Moscow+02 - Urals RU +5500+07324 Asia/Omsk Moscow+03 - west Siberia RU +5502+08255 Asia/Novosibirsk Moscow+03 - Novosibirsk RU +5345+08707 Asia/Novokuznetsk Moscow+03 (Moscow+04 after 2014-10-26) - Kemerovo RU +5601+09250 Asia/Krasnoyarsk Moscow+04 - Yenisei River RU +5216+10420 Asia/Irkutsk Moscow+05 - Lake Baikal RU +5203+11328 Asia/Chita Moscow+06 (Moscow+05 after 2014-10-26) - Zabaykalsky RU +6200+12940 Asia/Yakutsk Moscow+06 - Lena River RU +623923+1353314 Asia/Khandyga Moscow+06 - Tomponsky, Ust-Maysky RU +4310+13156 Asia/Vladivostok Moscow+07 - Amur River RU +4658+14242 Asia/Sakhalin Moscow+07 - Sakhalin Island RU +643337+1431336 Asia/Ust-Nera Moscow+07 - Oymyakonsky RU +5934+15048 Asia/Magadan Moscow+08 (Moscow+07 after 2014-10-26) - Magadan RU +6728+15343 Asia/Srednekolymsk Moscow+08 - E Sakha, N Kuril Is RU +5301+15839 Asia/Kamchatka Moscow+08 (Moscow+09 after 2014-10-26) - Kamchatka RU +6445+17729 Asia/Anadyr Moscow+08 (Moscow+09 after 2014-10-26) - Bering Sea SA,KW,YE +2438+04643 Asia/Riyadh SB -0932+16012 Pacific/Guadalcanal SC -0440+05528 Indian/Mahe SD,SS +1536+03232 Africa/Khartoum SE +5920+01803 Europe/Stockholm SG +0117+10351 Asia/Singapore SR +0550-05510 America/Paramaribo SV +1342-08912 America/El_Salvador SY +3330+03618 Asia/Damascus TC +2128-07108 America/Grand_Turk TD +1207+01503 Africa/Ndjamena TF -492110+0701303 Indian/Kerguelen Kerguelen, St Paul I, Amsterdam I TH,KH,LA,VN +1345+10031 Asia/Bangkok TJ +3835+06848 Asia/Dushanbe TK -0922-17114 Pacific/Fakaofo TL -0833+12535 Asia/Dili TM +3757+05823 Asia/Ashgabat TN +3648+01011 Africa/Tunis TO -2110-17510 Pacific/Tongatapu TR +4101+02858 Europe/Istanbul TT,AG,AI,BL,DM,GD,GP,MF,LC,KN,MS,VC,VG,VI +1039-06131 America/Port_of_Spain TV -0831+17913 Pacific/Funafuti TW +2503+12130 Asia/Taipei UA +5026+03031 Europe/Kiev most locations UA +4837+02218 Europe/Uzhgorod Ruthenia UA +4750+03510 Europe/Zaporozhye Zaporozh'ye, E Lugansk / Zaporizhia, E Luhansk UM +1917+16637 Pacific/Wake Wake Island US +404251-0740023 America/New_York Eastern Time US +421953-0830245 America/Detroit Eastern Time - Michigan - most locations US +381515-0854534 America/Kentucky/Louisville Eastern Time - Kentucky - Louisville area US +364947-0845057 America/Kentucky/Monticello Eastern Time - Kentucky - Wayne County US +394606-0860929 America/Indiana/Indianapolis Eastern Time - Indiana - most locations US +384038-0873143 America/Indiana/Vincennes Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties US +410305-0863611 America/Indiana/Winamac Eastern Time - Indiana - Pulaski County US +382232-0862041 America/Indiana/Marengo Eastern Time - Indiana - Crawford County US +382931-0871643 America/Indiana/Petersburg Eastern Time - Indiana - Pike County US +384452-0850402 America/Indiana/Vevay Eastern Time - Indiana - Switzerland County US +415100-0873900 America/Chicago Central Time US +375711-0864541 America/Indiana/Tell_City Central Time - Indiana - Perry County US +411745-0863730 America/Indiana/Knox Central Time - Indiana - Starke County US +450628-0873651 America/Menominee Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties US +470659-1011757 America/North_Dakota/Center Central Time - North Dakota - Oliver County US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - Morton County (except Mandan area) US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County US +394421-1045903 America/Denver Mountain Time US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon US +332654-1120424 America/Phoenix Mountain Standard Time - Arizona (except Navajo) US +340308-1181434 America/Los_Angeles Pacific Time US +550737-1313435 America/Metlakatla Pacific Standard Time - Annette Island, Alaska US +611305-1495401 America/Anchorage Alaska Time US +581807-1342511 America/Juneau Alaska Time - Alaska panhandle US +571035-1351807 America/Sitka Alaska Time - southeast Alaska panhandle US +593249-1394338 America/Yakutat Alaska Time - Alaska panhandle neck US +643004-1652423 America/Nome Alaska Time - west Alaska US +515248-1763929 America/Adak Aleutian Islands US,UM +211825-1575130 Pacific/Honolulu Hawaii time UY -3453-05611 America/Montevideo UZ +3940+06648 Asia/Samarkand west Uzbekistan UZ +4120+06918 Asia/Tashkent east Uzbekistan VE +1030-06656 America/Caracas VU -1740+16825 Pacific/Efate WF -1318-17610 Pacific/Wallis WS -1350-17144 Pacific/Apia ZA,LS,SZ -2615+02800 Africa/Johannesburg tzinfo-1.2.2/test/tc_transition_data_timezone_info.rb0000644000004100000410000005613612400401360023160 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTransitionDataTimezoneInfo < Minitest::Test def test_identifier dti = TransitionDataTimezoneInfo.new('Test/Zone') assert_equal('Test/Zone', dti.identifier) end def test_offset dti = TransitionDataTimezoneInfo.new('Test/Zone') assert_nothing_raised do dti.offset :o1, -18000, 3600, :TEST end end def test_offset_already_defined dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, 3600, 0, :TEST dti.offset :o2, 1800, 0, :TEST2 assert_raises(ArgumentError) { dti.offset :o1, 3600, 3600, :TESTD } end def test_transition_timestamp dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -18000, 3600, :TEST assert_nothing_raised do dti.transition 2006, 6, :o1, 1149368400 end end def test_transition_datetime dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -18000, 3600, :TEST assert_nothing_raised do dti.transition 2006, 6, :o1, 19631123, 8 end end def test_transition_timestamp_and_datetime dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -18000, 3600, :TEST assert_nothing_raised do dti.transition 2006, 6, :o1, 1149368400, 19631123, 8 end end def test_transition_invalid_offset dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -18000, 3600, :TEST dti.transition 2006, 6, :o1, 1149368400 assert_raises(ArgumentError) { dti.transition 2006, 6, :o2, 1149454800 } end def test_transition_no_offsets dti = TransitionDataTimezoneInfo.new('Test/Zone') assert_raises(ArgumentError) { dti.transition 2006, 6, :o1, 1149368400 } end def test_transition_invalid_order_month dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -18000, 3600, :TEST dti.transition 2006, 6, :o1, 1149368400 assert_raises(ArgumentError) { dti.transition 2006, 5, :o2, 1146690000 } end def test_transition_invalid_order_year dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -18000, 3600, :TEST dti.transition 2006, 6, :o1, 1149368400 assert_raises(ArgumentError) { dti.transition 2005, 7, :o2, 1120424400 } end def test_period_for_utc dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT dti.offset :o2, -18000, 3600, :TESTD dti.offset :o3, -18000, 0, :TESTS dti.offset :o4, -21600, 3600, :TESTD dti.transition 2000, 4, :o2, Time.utc(2000, 4,1,1,0,0).to_i dti.transition 2000, 10, :o3, Time.utc(2000,10,1,1,0,0).to_i dti.transition 2001, 3, :o2, 58847269, 24 # (2001, 3,1,1,0,0) dti.transition 2001, 4, :o4, Time.utc(2001, 4,1,1,0,0).to_i, 58848013, 24 dti.transition 2001, 10, :o3, Time.utc(2001,10,1,1,0,0).to_i dti.transition 2002, 10, :o3, Time.utc(2002,10,1,1,0,0).to_i dti.transition 2003, 2, :o2, Time.utc(2003, 2,1,1,0,0).to_i dti.transition 2003, 3, :o3, Time.utc(2003, 3,1,1,0,0).to_i o1 = TimezoneOffset.new(-17900, 0, :TESTLMT) o2 = TimezoneOffset.new(-18000, 3600, :TESTD) o3 = TimezoneOffset.new(-18000, 0, :TESTS) o4 = TimezoneOffset.new(-21600, 3600, :TESTD) t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2000, 4,1,1,0,0).to_i) t2 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2000,10,1,1,0,0).to_i) t3 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2001, 3,1,1,0,0).to_i) t4 = TimezoneTransitionDefinition.new(o4, o2, Time.utc(2001, 4,1,1,0,0).to_i) t5 = TimezoneTransitionDefinition.new(o3, o4, Time.utc(2001,10,1,1,0,0).to_i) t6 = TimezoneTransitionDefinition.new(o3, o3, Time.utc(2002,10,1,1,0,0).to_i) t7 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2003, 2,1,1,0,0).to_i) t8 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2003, 3,1,1,0,0).to_i) assert_equal(TimezonePeriod.new(nil, t1), dti.period_for_utc(DateTime.new(1960, 1,1,1, 0, 0))) assert_equal(TimezonePeriod.new(nil, t1), dti.period_for_utc(DateTime.new(1999,12,1,0, 0, 0))) assert_equal(TimezonePeriod.new(nil, t1), dti.period_for_utc(Time.utc( 2000, 4,1,0,59,59))) assert_equal(TimezonePeriod.new(t1, t2), dti.period_for_utc(DateTime.new(2000, 4,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t1, t2), dti.period_for_utc(Time.utc( 2000,10,1,0,59,59).to_i)) assert_equal(TimezonePeriod.new(t2, t3), dti.period_for_utc(Time.utc( 2000,10,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t2, t3), dti.period_for_utc(Time.utc( 2001, 3,1,0,59,59))) assert_equal(TimezonePeriod.new(t3, t4), dti.period_for_utc(Time.utc( 2001, 3,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t3, t4), dti.period_for_utc(Time.utc( 2001, 4,1,0,59,59))) assert_equal(TimezonePeriod.new(t4, t5), dti.period_for_utc(Time.utc( 2001, 4,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t4, t5), dti.period_for_utc(Time.utc( 2001,10,1,0,59,59))) assert_equal(TimezonePeriod.new(t5, t6), dti.period_for_utc(Time.utc( 2001,10,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t5, t6), dti.period_for_utc(Time.utc( 2002, 2,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t5, t6), dti.period_for_utc(Time.utc( 2002,10,1,0,59,59))) assert_equal(TimezonePeriod.new(t6, t7), dti.period_for_utc(Time.utc( 2002,10,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t6, t7), dti.period_for_utc(Time.utc( 2003, 2,1,0,59,59))) assert_equal(TimezonePeriod.new(t7, t8), dti.period_for_utc(Time.utc( 2003, 2,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t7, t8), dti.period_for_utc(Time.utc( 2003, 3,1,0,59,59))) assert_equal(TimezonePeriod.new(t8, nil), dti.period_for_utc(Time.utc( 2003, 3,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t8, nil), dti.period_for_utc(Time.utc( 2004, 1,1,1, 0, 0))) assert_equal(TimezonePeriod.new(t8, nil), dti.period_for_utc(DateTime.new(2050, 1,1,1, 0, 0))) end def test_period_for_utc_no_transitions dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT dti.offset :o2, -18000, 0, :TEST o1 = TimezoneOffset.new(-17900, 0, :TESTLMT) assert_equal(TimezonePeriod.new(nil, nil, o1), dti.period_for_utc(DateTime.new(2005,1,1,0,0,0))) assert_equal(TimezonePeriod.new(nil, nil, o1), dti.period_for_utc(Time.utc(2005,1,1,0,0,0))) assert_equal(TimezonePeriod.new(nil, nil, o1), dti.period_for_utc(Time.utc(2005,1,1,0,0,0).to_i)) end def test_period_for_utc_no_offsets dti = TransitionDataTimezoneInfo.new('Test/Zone') assert_raises(NoOffsetsDefined) { dti.period_for_utc(DateTime.new(2005,1,1,0,0,0)) } assert_raises(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0)) } assert_raises(NoOffsetsDefined) { dti.period_for_utc(Time.utc(2005,1,1,0,0,0).to_i) } end def test_periods_for_local dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT dti.offset :o2, -18000, 3600, :TESTD dti.offset :o3, -18000, 0, :TESTS dti.offset :o4, -21600, 3600, :TESTD dti.transition 2000, 4, :o2, 58839277, 24 # 2000,4,2,1,0,0 dti.transition 2000, 10, :o3, Time.utc(2000,10,2,1,0,0).to_i, 58843669, 24 dti.transition 2001, 3, :o2, Time.utc(2001, 3,2,1,0,0).to_i dti.transition 2001, 4, :o4, Time.utc(2001, 4,2,1,0,0).to_i dti.transition 2001, 10, :o3, Time.utc(2001,10,2,1,0,0).to_i dti.transition 2002, 10, :o3, 58861189, 24 # 2002,10,2,1,0,0 dti.transition 2003, 2, :o2, Time.utc(2003, 2,2,1,0,0).to_i o1 = TimezoneOffset.new(-17900, 0, :TESTLMT) o2 = TimezoneOffset.new(-18000, 3600, :TESTD) o3 = TimezoneOffset.new(-18000, 0, :TESTS) o4 = TimezoneOffset.new(-21600, 3600, :TESTD) t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2000, 4,2,1,0,0).to_i) t2 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2000,10,2,1,0,0).to_i) t3 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2001, 3,2,1,0,0).to_i) t4 = TimezoneTransitionDefinition.new(o4, o2, Time.utc(2001, 4,2,1,0,0).to_i) t5 = TimezoneTransitionDefinition.new(o3, o4, Time.utc(2001,10,2,1,0,0).to_i) t6 = TimezoneTransitionDefinition.new(o3, o3, Time.utc(2002,10,2,1,0,0).to_i) t7 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2003, 2,2,1,0,0).to_i) assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(DateTime.new(1960, 1, 1, 1, 0, 0))) assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(DateTime.new(1999,12, 1, 0, 0, 0))) assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(Time.utc( 2000, 1, 1,10, 0, 0))) assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(Time.utc( 2000, 4, 1,20, 1,39))) assert_equal([], dti.periods_for_local(Time.utc( 2000, 4, 1,20, 1,40))) assert_equal([], dti.periods_for_local(Time.utc( 2000, 4, 1,20,59,59))) assert_equal([TimezonePeriod.new(t1, t2)], dti.periods_for_local(Time.utc( 2000, 4, 1,21, 0, 0))) assert_equal([TimezonePeriod.new(t1, t2)], dti.periods_for_local(DateTime.new(2000,10, 1,19,59,59))) assert_equal([TimezonePeriod.new(t1, t2), TimezonePeriod.new(t2, t3)], dti.periods_for_local(Time.utc( 2000,10, 1,20, 0, 0).to_i)) assert_equal([TimezonePeriod.new(t1, t2), TimezonePeriod.new(t2, t3)], dti.periods_for_local(DateTime.new(2000,10, 1,20,59,59))) assert_equal([TimezonePeriod.new(t2, t3)], dti.periods_for_local(Time.utc( 2000,10, 1,21, 0, 0))) assert_equal([TimezonePeriod.new(t2, t3)], dti.periods_for_local(Time.utc( 2001, 3, 1,19,59,59))) assert_equal([], dti.periods_for_local(Time.utc( 2001, 3, 1,20, 0, 0))) assert_equal([], dti.periods_for_local(DateTime.new(2001, 3, 1,20, 30, 0))) assert_equal([], dti.periods_for_local(Time.utc( 2001, 3, 1,20,59,59).to_i)) assert_equal([TimezonePeriod.new(t3, t4)], dti.periods_for_local(Time.utc( 2001, 3, 1,21, 0, 0))) assert_equal([TimezonePeriod.new(t3, t4)], dti.periods_for_local(Time.utc( 2001, 4, 1,19,59,59))) assert_equal([TimezonePeriod.new(t3, t4), TimezonePeriod.new(t4, t5)], dti.periods_for_local(DateTime.new(2001, 4, 1,20, 0, 0))) assert_equal([TimezonePeriod.new(t3, t4), TimezonePeriod.new(t4, t5)], dti.periods_for_local(Time.utc( 2001, 4, 1,20,59,59))) assert_equal([TimezonePeriod.new(t4, t5)], dti.periods_for_local(Time.utc( 2001, 4, 1,21, 0, 0))) assert_equal([TimezonePeriod.new(t4, t5)], dti.periods_for_local(Time.utc( 2001,10, 1,19,59,59))) assert_equal([TimezonePeriod.new(t5, t6)], dti.periods_for_local(Time.utc( 2001,10, 1,20, 0, 0))) assert_equal([TimezonePeriod.new(t5, t6)], dti.periods_for_local(Time.utc( 2002, 2, 1,20, 0, 0))) assert_equal([TimezonePeriod.new(t5, t6)], dti.periods_for_local(Time.utc( 2002,10, 1,19,59,59))) assert_equal([TimezonePeriod.new(t6, t7)], dti.periods_for_local(Time.utc( 2002,10, 1,20, 0, 0))) assert_equal([TimezonePeriod.new(t6, t7)], dti.periods_for_local(Time.utc( 2003, 2, 1,19,59,59))) assert_equal([], dti.periods_for_local(Time.utc( 2003, 2, 1,20, 0, 0))) assert_equal([], dti.periods_for_local(Time.utc( 2003, 2, 1,20,59,59))) assert_equal([TimezonePeriod.new(t7, nil)], dti.periods_for_local(Time.utc( 2003, 2, 1,21, 0, 0))) assert_equal([TimezonePeriod.new(t7, nil)], dti.periods_for_local(Time.utc( 2004, 2, 1,20, 0, 0))) assert_equal([TimezonePeriod.new(t7, nil)], dti.periods_for_local(DateTime.new(2040, 2, 1,20, 0, 0))) end def test_periods_for_local_warsaw dti = TransitionDataTimezoneInfo.new('Test/Europe/Warsaw') dti.offset :o1, 5040, 0, :LMT dti.offset :o2, 5040, 0, :WMT dti.offset :o3, 3600, 0, :CET dti.offset :o4, 3600, 3600, :CEST dti.transition 1879, 12, :o2, 288925853, 120 # 1879,12,31,22,36,0 dti.transition 1915, 8, :o3, 290485733, 120 # 1915, 8, 4,22,36,0 dti.transition 1916, 4, :o4, 29051813, 12 # 1916, 4,30,22, 0,0 o1 = TimezoneOffset.new(5040, 0, :LMT) o2 = TimezoneOffset.new(5040, 0, :WMT) o3 = TimezoneOffset.new(3600, 0, :CET) o4 = TimezoneOffset.new(3600, 3600, :CEST) t1 = TimezoneTransitionDefinition.new(o2, o1, 288925853, 120) t2 = TimezoneTransitionDefinition.new(o3, o2, 290485733, 120) t3 = TimezoneTransitionDefinition.new(o4, o3, 29051813, 12) assert_equal([TimezonePeriod.new(t1, t2), TimezonePeriod.new(t2, t3)], dti.periods_for_local(DateTime.new(1915,8,4,23,40,0))) end def test_periods_for_local_boundary dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -3600, 0, :TESTD dti.offset :o2, -3600, 0, :TESTS dti.transition 2000, 7, :o2, Time.utc(2000,7,1,0,0,0).to_i o1 = TimezoneOffset.new(-3600, 0, :TESTD) o2 = TimezoneOffset.new(-3600, 0, :TESTS) t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2000,7,1,0,0,0).to_i) # 2000-07-01 00:00:00 UTC is 2000-06-30 23:00:00 UTC-1 # hence to find periods for local times between 2000-06-30 23:00:00 # and 2000-07-01 00:00:00 a search has to be carried out in the next half # year to the one containing the date we are looking for assert_equal([TimezonePeriod.new(nil, t1)], dti.periods_for_local(Time.utc(2000,6,30,22,59,59))) assert_equal([TimezonePeriod.new(t1, nil)], dti.periods_for_local(Time.utc(2000,6,30,23, 0, 0))) assert_equal([TimezonePeriod.new(t1, nil)], dti.periods_for_local(Time.utc(2000,7, 1, 0, 0, 0))) end def test_periods_for_local_no_transitions dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT dti.offset :o2, -18000, 0, :TEST o1 = TimezoneOffset.new(-17900, 0, :TESTLMT) assert_equal([TimezonePeriod.new(nil, nil, o1)], dti.periods_for_local(DateTime.new(2005,1,1,0,0,0))) assert_equal([TimezonePeriod.new(nil, nil, o1)], dti.periods_for_local(Time.utc(2005,1,1,0,0,0))) assert_equal([TimezonePeriod.new(nil, nil, o1)], dti.periods_for_local(Time.utc(2005,1,1,0,0,0).to_i)) end def test_periods_for_local_no_offsets dti = TransitionDataTimezoneInfo.new('Test/Zone') assert_raises(NoOffsetsDefined) { dti.periods_for_local(DateTime.new(2005,1,1,0,0,0)) } assert_raises(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0)) } assert_raises(NoOffsetsDefined) { dti.periods_for_local(Time.utc(2005,1,1,0,0,0).to_i) } end def test_transitions_up_to dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT dti.offset :o2, -18000, 3600, :TESTD dti.offset :o3, -18000, 0, :TESTS dti.offset :o4, -21600, 3600, :TESTD dti.transition 2010, 4, :o2, Time.utc(2010, 4,1,1,0,0).to_i dti.transition 2010, 10, :o3, Time.utc(2010,10,1,1,0,0).to_i dti.transition 2011, 3, :o2, 58934917, 24 # (2011, 3,1,1,0,0) dti.transition 2011, 4, :o4, Time.utc(2011, 4,1,1,0,0).to_i, 58935661, 24 dti.transition 2011, 10, :o3, Time.utc(2011,10,1,1,0,0).to_i o1 = TimezoneOffset.new(-17900, 0, :TESTLMT) o2 = TimezoneOffset.new(-18000, 3600, :TESTD) o3 = TimezoneOffset.new(-18000, 0, :TESTS) o4 = TimezoneOffset.new(-21600, 3600, :TESTD) t1 = TimezoneTransitionDefinition.new(o2, o1, Time.utc(2010, 4,1,1,0,0).to_i) t2 = TimezoneTransitionDefinition.new(o3, o2, Time.utc(2010,10,1,1,0,0).to_i) t3 = TimezoneTransitionDefinition.new(o2, o3, Time.utc(2011, 3,1,1,0,0).to_i) t4 = TimezoneTransitionDefinition.new(o4, o2, Time.utc(2011, 4,1,1,0,0).to_i) t5 = TimezoneTransitionDefinition.new(o3, o4, Time.utc(2011,10,1,1,0,0).to_i) assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0))) assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0), Time.utc(2000,1,1,0,0,0))) assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1))) assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1), Time.utc(2000,1,1,0,0,0))) assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,4,1,1,0,1), Time.utc(2010,10,1,1,0,0))) assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0), Time.utc(2010,4,1,1,0,1))) assert_equal([t3], dti.transitions_up_to(Time.utc(2011,4,1,1,0,0), Time.utc(2010,10,1,1,0,1))) assert_equal([], dti.transitions_up_to(Time.utc(2011,3,1,1,0,0), Time.utc(2010,10,1,1,0,1))) assert_equal([t1,t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0))) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1))) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0,1))) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1), Time.utc(2010,4,1,1,0,0))) assert_equal([t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1), Time.utc(2010,4,1,1,0,1))) assert_equal([t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1), Time.utc(2010,4,1,1,0,0,1))) assert_equal([t5], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0), Time.utc(2011,10,1,1,0,0))) assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0), Time.utc(2011,10,1,1,0,1))) assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0).to_i)) assert_equal([], dti.transitions_up_to(Time.utc(2010,4,1,1,0,0).to_i, Time.utc(2000,1,1,0,0,0).to_i)) assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1).to_i)) assert_equal([t1], dti.transitions_up_to(Time.utc(2010,4,1,1,0,1).to_i, Time.utc(2000,1,1,0,0,0).to_i)) assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,4,1,1,0,1).to_i, Time.utc(2010,10,1,1,0,0).to_i)) assert_equal([t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0).to_i, Time.utc(2010,4,1,1,0,1).to_i)) assert_equal([t3], dti.transitions_up_to(Time.utc(2011,4,1,1,0,0).to_i, Time.utc(2010,10,1,1,0,1).to_i)) assert_equal([], dti.transitions_up_to(Time.utc(2011,3,1,1,0,0).to_i, Time.utc(2010,10,1,1,0,1).to_i)) assert_equal([t1,t2,t3,t4], dti.transitions_up_to(Time.utc(2011,10,1,1,0,0).to_i)) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1).to_i)) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,0).to_i)) assert_equal([t2,t3,t4,t5], dti.transitions_up_to(Time.utc(2011,10,1,1,0,1).to_i, Time.utc(2010,4,1,1,0,1).to_i)) assert_equal([t5], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0).to_i, Time.utc(2011,10,1,1,0,0).to_i)) assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0).to_i, Time.utc(2011,10,1,1,0,1).to_i)) assert_equal([], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,0))) assert_equal([], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,0), DateTime.new(2000,1,1,0,0,0))) assert_equal([t1], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,1))) assert_equal([t1], dti.transitions_up_to(DateTime.new(2010,4,1,1,0,1), DateTime.new(2000,1,1,0,0,0))) assert_equal([t2,t3,t4], dti.transitions_up_to(DateTime.new(2011,4,1,1,0,1), DateTime.new(2010,10,1,1,0,0))) assert_equal([t2,t3,t4], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,0), DateTime.new(2010,4,1,1,0,1))) assert_equal([t3], dti.transitions_up_to(DateTime.new(2011,4,1,1,0,0), DateTime.new(2010,10,1,1,0,1))) assert_equal([], dti.transitions_up_to(DateTime.new(2011,3,1,1,0,0), DateTime.new(2010,10,1,1,0,1))) assert_equal([t1,t2,t3,t4], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,0))) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1))) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,Rational(DATETIME_RESOLUTION,1000000)))) assert_equal([t1,t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,0))) assert_equal([t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,1))) assert_equal([t2,t3,t4,t5], dti.transitions_up_to(DateTime.new(2011,10,1,1,0,1), DateTime.new(2010,4,1,1,0,Rational(DATETIME_RESOLUTION,1000000)))) assert_equal([t5], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,0))) assert_equal([], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0), DateTime.new(2011,10,1,1,0,1))) end def test_transitions_up_to_no_transitions dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0))) assert_equal([], dti.transitions_up_to(Time.utc(2015,1,1,0,0,0).to_i)) assert_equal([], dti.transitions_up_to(DateTime.new(2015,1,1,0,0,0))) end def test_transitions_up_to_utc_to_not_greater_than_utc_from dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, -17900, 0, :TESTLMT assert_raises(ArgumentError) do dti.transitions_up_to(Time.utc(2012,8,1,0,0,0), Time.utc(2013,8,1,0,0,0)) end assert_raises(ArgumentError) do dti.transitions_up_to(Time.utc(2012,8,1,0,0,0).to_i, Time.utc(2012,8,1,0,0,0).to_i) end assert_raises(ArgumentError) do dti.transitions_up_to(DateTime.new(2012,8,1,0,0,0), DateTime.new(2012,8,1,0,0,0)) end end def test_datetime_and_timestamp_use dti = TransitionDataTimezoneInfo.new('Test/Zone') dti.offset :o1, 0, 0, :TESTS dti.offset :o2, 0, 3600, :TESTD dti.transition 1901, 12, :o2, -2147483649, 69573092117, 28800 dti.transition 1969, 12, :o1, -1, 210866759999, 86400 dti.transition 2001, 9, :o2, 1000000000, 529666909, 216 dti.transition 2038, 1, :o1, 2147483648, 3328347557, 1350 if RubyCoreSupport.time_supports_negative && RubyCoreSupport.time_supports_64bit assert(dti.period_for_utc(DateTime.new(1901,12,13,20,45,51)).start_transition.at.eql?(TimeOrDateTime.new(-2147483649))) else assert(dti.period_for_utc(DateTime.new(1901,12,13,20,45,51)).start_transition.at.eql?(TimeOrDateTime.new(DateTime.new(1901,12,13,20,45,51)))) end if RubyCoreSupport.time_supports_negative assert(dti.period_for_utc(DateTime.new(1969,12,31,23,59,59)).start_transition.at.eql?(TimeOrDateTime.new(-1))) else assert(dti.period_for_utc(DateTime.new(1969,12,31,23,59,59)).start_transition.at.eql?(TimeOrDateTime.new(DateTime.new(1969,12,31,23,59,59)))) end assert(dti.period_for_utc(DateTime.new(2001,9,9,2,46,40)).start_transition.at.eql?(TimeOrDateTime.new(1000000000))) if RubyCoreSupport.time_supports_64bit assert(dti.period_for_utc(DateTime.new(2038,1,19,3,14,8)).start_transition.at.eql?(TimeOrDateTime.new(2147483648))) else assert(dti.period_for_utc(DateTime.new(2038,1,19,3,14,8)).start_transition.at.eql?(TimeOrDateTime.new(DateTime.new(2038,1,19,3,14,8)))) end end end tzinfo-1.2.2/test/tc_data_timezone_info.rb0000644000004100000410000000070012400401360020670 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCDataTimezoneInfo < Minitest::Test def test_identifier ti = DataTimezoneInfo.new('Test/Zone') assert_equal('Test/Zone', ti.identifier) end def test_construct_timezone ti = DataTimezoneInfo.new('Test/Zone') tz = ti.create_timezone assert_kind_of(DataTimezone, tz) assert_equal('Test/Zone', tz.identifier) end end tzinfo-1.2.2/test/tc_offset_rationals.rb0000644000004100000410000000126212400401360020400 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCOffsetRationals < Minitest::Test def test_rational_for_offset [0,1,2,3,4,-1,-2,-3,-4,30*60,-30*60,61*60,-61*60,14*60*60,-14*60*60,20*60*60,-20*60*60].each {|seconds| assert_equal(Rational(seconds, 86400), OffsetRationals.rational_for_offset(seconds)) } end def test_rational_for_offset_constant -28.upto(28) {|i| seconds = i * 30 * 60 r1 = OffsetRationals.rational_for_offset(seconds) r2 = OffsetRationals.rational_for_offset(seconds) assert_equal(Rational(seconds, 86400), r1) assert_same(r1, r2) } end end tzinfo-1.2.2/test/ts_all_zoneinfo.rb0000644000004100000410000000060212400401360017532 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils.rb') # Use a zoneinfo directory containing files needed by the tests. # The symlinks in this directory are set up in test_utils.rb. TZInfo::DataSource.set(:zoneinfo, File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo').untaint) require File.join(File.expand_path(File.dirname(__FILE__)), 'ts_all.rb') tzinfo-1.2.2/test/tc_zoneinfo_timezone_info.rb0000644000004100000410000010105212400401360021610 0ustar www-datawww-data# encoding: UTF-8 require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') require 'tempfile' include TZInfo class TCZoneinfoTimezoneInfo < Minitest::Test begin Time.at(-2147483649) Time.at(2147483648) SUPPORTS_64BIT = true rescue RangeError SUPPORTS_64BIT = false end begin Time.at(-1) Time.at(-2147483648) SUPPORTS_NEGATIVE = true rescue ArgumentError SUPPORTS_NEGATIVE = false end def assert_period(abbreviation, utc_offset, std_offset, dst, start_at, end_at, info) if start_at period = info.period_for_utc(start_at) elsif end_at period = info.period_for_utc(TimeOrDateTime.wrap(end_at).add_with_convert(-1).to_orig) else # no transitions, pick the epoch period = info.period_for_utc(Time.utc(1970, 1, 1)) end assert_equal(abbreviation, period.abbreviation) assert_equal(utc_offset, period.utc_offset) assert_equal(std_offset, period.std_offset) assert_equal(dst, period.dst?) if start_at refute_nil(period.utc_start_time) assert_equal(start_at, period.utc_start_time) else assert_nil(period.utc_start_time) end if end_at refute_nil(period.utc_end_time) assert_equal(end_at, period.utc_end_time) else assert_nil(period.utc_end_time) end end def convert_times_to_i(items, key = :at) items.each do |item| if item[key].kind_of?(Time) item[key] = item[key].utc.to_i end end end def select_with_32bit_values(items, key = :at) items.select do |item| i = item[key] i >= -2147483648 && i <= 2147483647 end end def pack_int64_network_order(values) values.collect {|value| [value >> 32, value & 0xFFFFFFFF]}.flatten.pack('NN' * values.length) end def pack_int64_signed_network_order(values) # Convert to the equivalent 64-bit unsigned integer with the same bit representation pack_int64_network_order(values.collect {|value| value < 0 ? value + 0x10000000000000000 : value}) end def write_tzif(format, offsets, transitions, leaps = [], options = {}) # Options for testing malformed zoneinfo files. magic = options[:magic] section2_magic = options[:section2_magic] abbrev_separator = options[:abbrev_separator] || "\0" abbrev_offset_base = options[:abbrev_offset_base] || 0 unless magic if format == 1 magic = "TZif\0" elsif format >= 2 magic = "TZif#{format}" else raise ArgumentError, 'Invalid format specified' end end if section2_magic.kind_of?(Proc) section2_magic = section2_magic.call(format) else section2_magic = magic unless section2_magic end convert_times_to_i(transitions) convert_times_to_i(leaps) abbrevs = offsets.collect {|o| o[:abbrev]}.uniq if abbrevs.length > 0 abbrevs = abbrevs.collect {|a| a.encode('UTF-8')} if abbrevs.first.respond_to?(:encode) if abbrevs.first.respond_to?(:bytesize) abbrevs_length = abbrevs.inject(0) {|sum, a| sum + a.bytesize + abbrev_separator.bytesize} else abbrevs_length = abbrevs.inject(0) {|sum, a| sum + a.length + abbrev_separator.length} end else abbrevs_length = 0 end b32_transitions = select_with_32bit_values(transitions) b32_leaps = select_with_32bit_values(leaps) Tempfile.open('tzinfo-test-zone') do |file| file.binmode file.write( [magic, offsets.length, offsets.length, leaps.length, b32_transitions.length, offsets.length, abbrevs_length].pack('a5 x15 NNNNNN')) unless b32_transitions.empty? file.write(b32_transitions.collect {|t| t[:at]}.pack('N' * b32_transitions.length)) file.write(b32_transitions.collect {|t| t[:offset_index]}.pack('C' * b32_transitions.length)) end offsets.each do |offset| index = abbrevs.index(offset[:abbrev]) abbrev_offset = abbrev_offset_base 0.upto(index - 1) {|i| abbrev_offset += abbrevs[i].length + 1} file.write([offset[:gmtoff], offset[:isdst] ? 1 : 0, abbrev_offset].pack('NCC')) end abbrevs.each do |a| file.write(a) file.write(abbrev_separator) end b32_leaps.each do |leap| file.write([leap[:at], leap[:seconds]].pack('NN')) end unless offsets.empty? file.write("\0" * offsets.length * 2) end if format >= 2 file.write( [section2_magic, offsets.length, offsets.length, leaps.length, transitions.length, offsets.length, abbrevs_length].pack('a5 x15 NNNNNN')) unless transitions.empty? file.write(pack_int64_signed_network_order(transitions.collect {|t| t[:at]})) file.write(transitions.collect {|t| t[:offset_index]}.pack('C' * transitions.length)) end offsets.each do |offset| index = abbrevs.index(offset[:abbrev]) abbrev_offset = abbrev_offset_base 0.upto(index - 1) {|i| abbrev_offset += abbrevs[i].length + 1} file.write([offset[:gmtoff], offset[:isdst] ? 1 : 0, abbrev_offset].pack('NCC')) end abbrevs.each do |a| file.write(a) file.write(abbrev_separator) end leaps.each do |leap| file.write(pack_int64_signed_network_order([leap[:at]])) file.write([leap[:seconds]].pack('N')) end unless offsets.empty? file.write("\0" * offsets.length * 2) end # Empty POSIX timezone string file.write("\n\n") end file.flush yield file.path, format end end def tzif_test(offsets, transitions, leaps = [], options = {}, &block) min_format = options[:min_format] || 1 min_format.upto(3) do |format| write_tzif(format, offsets, transitions, leaps, options, &block) end end def test_load offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 0, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => Time.utc(1971, 1, 2), :offset_index => 1}, {:at => Time.utc(1980, 4, 22), :offset_index => 2}, {:at => Time.utc(1980, 10, 21), :offset_index => 1}, {:at => Time.utc(2000, 12, 31), :offset_index => 3}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/One', path) assert_equal('Zone/One', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(1971, 1, 2), info) assert_period(:XST, 3600, 0, false, Time.utc(1971, 1, 2), Time.utc(1980, 4, 22), info) assert_period(:XDT, 3600, 3600, true, Time.utc(1980, 4, 22), Time.utc(1980, 10, 21), info) assert_period(:XST, 3600, 0, false, Time.utc(1980, 10, 21), Time.utc(2000, 12, 31), info) assert_period(:XNST, 0, 0, false, Time.utc(2000, 12, 31), nil, info) end end def test_load_negative_utc_offset offsets = [ {:gmtoff => -12492, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => -12000, :isdst => false, :abbrev => 'XST'}, {:gmtoff => -8400, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => -8400, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => Time.utc(1971, 7, 9, 3, 0, 0), :offset_index => 1}, {:at => Time.utc(1972, 10, 12, 3, 0, 0), :offset_index => 2}, {:at => Time.utc(1973, 4, 29, 3, 0, 0), :offset_index => 1}, {:at => Time.utc(1992, 4, 1, 4, 30, 0), :offset_index => 3}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/One', path) assert_equal('Zone/One', info.identifier) assert_period(:LMT, -12492, 0, false, nil, Time.utc(1971, 7, 9, 3, 0, 0), info) assert_period(:XST, -12000, 0, false, Time.utc(1971, 7, 9, 3, 0, 0), Time.utc(1972, 10, 12, 3, 0, 0), info) assert_period(:XDT, -12000, 3600, true, Time.utc(1972, 10, 12, 3, 0, 0), Time.utc(1973, 4, 29, 3, 0, 0), info) assert_period(:XST, -12000, 0, false, Time.utc(1973, 4, 29, 3, 0, 0), Time.utc(1992, 4, 1, 4, 30, 0), info) assert_period(:XNST, -8400, 0, false, Time.utc(1992, 4, 1, 4, 30, 0), nil, info) end end def test_load_dst_first offsets = [ {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 0, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => Time.utc(1979, 1, 2), :offset_index => 2}, {:at => Time.utc(1980, 4, 22), :offset_index => 0}, {:at => Time.utc(1980, 10, 21), :offset_index => 2}, {:at => Time.utc(2000, 12, 31), :offset_index => 3}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/Two', path) assert_equal('Zone/Two', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(1979, 1, 2), info) end end def test_load_no_transitions offsets = [{:gmtoff => -12094, :isdst => false, :abbrev => 'LT'}] tzif_test(offsets, []) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/three', path) assert_equal('Zone/three', info.identifier) assert_period(:LT, -12094, 0, false, nil, nil, info) end end def test_load_invalid_offset_index offsets = [{:gmtoff => -0, :isdst => false, :abbrev => 'LMT'}] transitions = [{:at => Time.utc(2000, 12, 31), :offset_index => 2}] tzif_test(offsets, transitions) do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone', path) end end end def test_load_with_leap_seconds offsets = [{:gmtoff => -0, :isdst => false, :abbrev => 'LMT'}] leaps = [{:at => Time.utc(1972,6,30,23,59,60), :seconds => 1}] tzif_test(offsets, [], leaps) do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone', path) end end end def test_load_invalid_magic ['TZif4', 'tzif2', '12345'].each do |magic| offsets = [{:gmtoff => -12094, :isdst => false, :abbrev => 'LT'}] tzif_test(offsets, [], [], :magic => magic) do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone2', path) end end end end # These tests can only be run if the platform supports 64-bit Times. When # 64-bit support is unavailable, the second section will not be read, so no # error will be raised. if SUPPORTS_64BIT def test_load_invalid_section2_magic ['TZif4', 'tzif2', '12345'].each do |section2_magic| offsets = [{:gmtoff => -12094, :isdst => false, :abbrev => 'LT'}] tzif_test(offsets, [], [], :min_format => 2, :section2_magic => section2_magic) do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone4', path) end end end end def test_load_mismatched_section2_magic minus_one = Proc.new {|f| f == 2 ? "TZif\0" : "TZif#{f - 1}" } plus_one = Proc.new {|f| "TZif#{f + 1}" } [minus_one, plus_one].each do |section2_magic| offsets = [{:gmtoff => -12094, :isdst => false, :abbrev => 'LT'}] tzif_test(offsets, [], [], :min_format => 2, :section2_magic => section2_magic) do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone5', path) end end end end end def test_load_invalid_format Tempfile.open('tzinfo-test-zone') do |file| file.write('Invalid') file.flush assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone3', file.path) end end end def test_load_missing_abbrev_null_termination offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 1}] tzif_test(offsets, transitions, [], :abbrev_separator => '^') do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone', path) end end end def test_load_out_of_range_abbrev_offsets offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 1}] tzif_test(offsets, transitions, [], :abbrev_offset_base => 8) do |path, format| assert_raises(InvalidZoneinfoFile) do ZoneinfoTimezoneInfo.new('Zone', path) end end end def test_load_before_epoch # Some platforms don't support negative timestamps for times before the # epoch. Check that they are returned when supported and skipped when not. # Note the last transition before the epoch (and within the 32-bit range) is # moved to the epoch on platforms that do not support negative timestamps. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 0, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => -694224000, :offset_index => 1}, # Time.utc(1948, 1, 2) {:at => -21945600, :offset_index => 2}, # Time.utc(1969, 4, 22) {:at => Time.utc(1970, 10, 21), :offset_index => 1}, {:at => Time.utc(2000, 12, 31), :offset_index => 3}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/Negative', path) assert_equal('Zone/Negative', info.identifier) if SUPPORTS_NEGATIVE assert_period(:LMT, 3542, 0, false, nil, Time.utc(1948, 1, 2), info) assert_period(:XST, 3600, 0, false, Time.utc(1948, 1, 2), Time.utc(1969, 4, 22), info) assert_period(:XDT, 3600, 3600, true, Time.utc(1969, 4, 22), Time.utc(1970, 10, 21), info) else assert_period(:LMT, 3542, 0, false, nil, Time.utc(1970, 1, 1), info) assert_period(:XDT, 3600, 3600, true, Time.utc(1970, 1, 1), Time.utc(1970, 10, 21), info) end assert_period(:XST, 3600, 0, false, Time.utc(1970, 10, 21), Time.utc(2000, 12, 31), info) assert_period(:XNST, 0, 0, false, Time.utc(2000, 12, 31), nil, info) end end def test_load_on_epoch offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 0, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => -694224000, :offset_index => 1}, # Time.utc(1948, 1, 2) {:at => -21945600, :offset_index => 2}, # Time.utc(1969, 4, 22) {:at => Time.utc(1970, 1, 1), :offset_index => 1}, {:at => Time.utc(2000, 12, 31), :offset_index => 3}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/Negative', path) assert_equal('Zone/Negative', info.identifier) if SUPPORTS_NEGATIVE assert_period(:LMT, 3542, 0, false, nil, Time.utc(1948, 1, 2), info) assert_period(:XST, 3600, 0, false, Time.utc(1948, 1, 2), Time.utc(1969, 4, 22), info) assert_period(:XDT, 3600, 3600, true, Time.utc(1969, 4, 22), Time.utc(1970, 1, 1), info) else assert_period(:LMT, 3542, 0, false, nil, Time.utc(1970, 1, 1), info) end assert_period(:XST, 3600, 0, false, Time.utc(1970, 1, 1), Time.utc(2000, 12, 31), info) assert_period(:XNST, 0, 0, false, Time.utc(2000, 12, 31), nil, info) end end def test_load_64bit # Some platforms support 64-bit Times, others only 32-bit. The TZif version # 2 and later format contains both 32-bit and 64-bit times. # Where 64-bit is supported and a TZif 2 or later file is provided, the # 64-bit times should be used, otherwise the 32-bit information should be # used. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 0, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => -3786739200, :offset_index => 1}, # Time.utc(1850, 1, 2) {:at => Time.utc(2003, 4, 22), :offset_index => 2}, {:at => Time.utc(2003, 10, 21), :offset_index => 1}, {:at => 2240524800, :offset_index => 3}] # Time.utc(2040, 12, 31) tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/SixtyFour', path) assert_equal('Zone/SixtyFour', info.identifier) if SUPPORTS_64BIT && format >= 2 assert_period(:LMT, 3542, 0, false, nil, Time.utc(1850, 1, 2), info) assert_period(:XST, 3600, 0, false, Time.utc(1850, 1, 2), Time.utc(2003, 4, 22), info) assert_period(:XDT, 3600, 3600, true, Time.utc(2003, 4, 22), Time.utc(2003, 10, 21), info) assert_period(:XST, 3600, 0, false, Time.utc(2003, 10, 21), Time.utc(2040, 12, 31), info) assert_period(:XNST, 0, 0, false, Time.utc(2040, 12, 31), nil, info) else assert_period(:LMT, 3542, 0, false, nil, Time.utc(2003, 4, 22), info) assert_period(:XDT, 3600, 3600, true, Time.utc(2003, 4, 22), Time.utc(2003, 10, 21), info) assert_period(:XST, 3600, 0, false, Time.utc(2003, 10, 21), nil, info) end end end def test_load_64bit_range # The full range of 64 bit timestamps is not currently supported because of # the way transitions are indexed. Transitions outside the supported range # will be ignored. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => -2**63, :offset_index => 1}, {:at => Time.utc(2014, 5, 27), :offset_index => 2}, {:at => 2**63 - 1, :offset_index => 0}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/SixtyFourRange', path) assert_equal('Zone/SixtyFourRange', info.identifier) if SUPPORTS_64BIT && format >= 2 # When the full range is supported, the following periods will be defined: #assert_period(:LMT, 3542, 0, false, nil, Time.at(-2**63).utc, info) #assert_period(:XST, 3600, 0, false, Time.at(-2**63).utc, Time.utc(2014, 5, 27), info) #assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), Time.at(2**63 - 1).utc, info) #assert_period(:LMT, 3542, 0, false, Time.at(2**63 - 1).utc, nil, info) # Without full range support, the following periods will be defined: assert_period(:LMT, 3542, 0, false, nil, Time.utc(2014, 5, 27), info) assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), nil, info) else assert_period(:LMT, 3542, 0, false, nil, Time.utc(2014, 5, 27), info) assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), nil, info) end end end def test_load_supported_64bit_range # The full range of 64 bit timestamps is not currently supported because of # the way transitions are indexed. Transitions outside the supported range # will be ignored. min_timestamp = -8520336000 # Time.utc(1700, 1, 1).to_i max_timestamp = 16725225600 # Time.utc(2500, 1, 1).to_i offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => min_timestamp, :offset_index => 1}, {:at => Time.utc(2014, 5, 27), :offset_index => 2}, {:at => max_timestamp - 1, :offset_index => 0}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/SupportedSixtyFourRange', path) assert_equal('Zone/SupportedSixtyFourRange', info.identifier) if SUPPORTS_64BIT && format >= 2 assert_period(:LMT, 3542, 0, false, nil, Time.at(min_timestamp).utc, info) assert_period(:XST, 3600, 0, false, Time.at(min_timestamp).utc, Time.utc(2014, 5, 27), info) assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), Time.at(max_timestamp - 1).utc, info) assert_period(:LMT, 3542, 0, false, Time.at(max_timestamp - 1).utc, nil, info) else assert_period(:LMT, 3542, 0, false, nil, Time.utc(2014, 5, 27), info) assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), nil, info) end end end def test_load_32bit_range offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => false, :abbrev => 'XNST'}] transitions = [ {:at => -2**31, :offset_index => 1}, {:at => Time.utc(2014, 5, 27), :offset_index => 2}, {:at => 2**31 - 1, :offset_index => 0}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/ThirtyTwoRange', path) assert_equal('Zone/ThirtyTwoRange', info.identifier) if SUPPORTS_NEGATIVE assert_period(:LMT, 3542, 0, false, nil, Time.at(-2**31).utc, info) assert_period(:XST, 3600, 0, false, Time.at(-2**31).utc, Time.utc(2014, 5, 27), info) assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), Time.at(2**31 - 1).utc, info) assert_period(:LMT, 3542, 0, false, Time.at(2**31 - 1).utc, nil, info) else assert_period(:XST, 3600, 0, false, Time.utc(1970, 1, 1), Time.utc(2014, 5, 27), info) assert_period(:XNST, 7200, 0, false, Time.utc(2014, 5, 27), Time.at(2**31 - 1).utc, info) assert_period(:LMT, 3542, 0, false, Time.at(2**31 - 1).utc, nil, info) end end end def test_load_std_offset_changes # The zoneinfo files don't include the offset from standard time, so this # has to be derived by looking at changes in the total UTC offset. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 10800, :isdst => true, :abbrev => 'XDDT'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 1}, {:at => Time.utc(2000, 2, 1), :offset_index => 2}, {:at => Time.utc(2000, 3, 1), :offset_index => 3}, {:at => Time.utc(2000, 4, 1), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/DoubleDaylight', path) assert_equal('Zone/DoubleDaylight', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(2000, 1, 1), info) assert_period(:XST, 3600, 0, false, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info) assert_period(:XDT, 3600, 3600, true, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info) assert_period(:XDDT, 3600, 7200, true, Time.utc(2000, 3, 1), Time.utc(2000, 4, 1), info) assert_period(:XST, 3600, 0, false, Time.utc(2000, 4, 1), nil, info) end end def test_load_std_offset_changes_jump_to_double_dst # The zoneinfo files don't include the offset from standard time, so this # has to be derived by looking at changes in the total UTC offset. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 10800, :isdst => true, :abbrev => 'XDDT'}] transitions = [ {:at => Time.utc(2000, 4, 1), :offset_index => 1}, {:at => Time.utc(2000, 5, 1), :offset_index => 2}, {:at => Time.utc(2000, 6, 1), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/DoubleDaylight', path) assert_equal('Zone/DoubleDaylight', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(2000, 4, 1), info) assert_period(:XST, 3600, 0, false, Time.utc(2000, 4, 1), Time.utc(2000, 5, 1), info) assert_period(:XDDT, 3600, 7200, true, Time.utc(2000, 5, 1), Time.utc(2000, 6, 1), info) assert_period(:XST, 3600, 0, false, Time.utc(2000, 6, 1), nil, info) end end def test_load_std_offset_changes_negative # The zoneinfo files don't include the offset from standard time, so this # has to be derived by looking at changes in the total UTC offset. offsets = [ {:gmtoff => -10821, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => -10800, :isdst => false, :abbrev => 'XST'}, {:gmtoff => -7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => -3600, :isdst => true, :abbrev => 'XDDT'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 1}, {:at => Time.utc(2000, 2, 1), :offset_index => 2}, {:at => Time.utc(2000, 3, 1), :offset_index => 3}, {:at => Time.utc(2000, 4, 1), :offset_index => 1}, {:at => Time.utc(2000, 5, 1), :offset_index => 3}, {:at => Time.utc(2000, 6, 1), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/DoubleDaylight', path) assert_equal('Zone/DoubleDaylight', info.identifier) assert_period(:LMT, -10821, 0, false, nil, Time.utc(2000, 1, 1), info) assert_period(:XST, -10800, 0, false, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info) assert_period(:XDT, -10800, 3600, true, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info) assert_period(:XDDT, -10800, 7200, true, Time.utc(2000, 3, 1), Time.utc(2000, 4, 1), info) assert_period(:XST, -10800, 0, false, Time.utc(2000, 4, 1), Time.utc(2000, 5, 1), info) assert_period(:XDDT, -10800, 7200, true, Time.utc(2000, 5, 1), Time.utc(2000, 6, 1), info) assert_period(:XST, -10800, 0, false, Time.utc(2000, 6, 1), nil, info) end end def test_load_starts_two_hour_std_offset # The zoneinfo files don't include the offset from standard time, so this # has to be derived by looking at changes in the total UTC offset. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDT'}, {:gmtoff => 10800, :isdst => true, :abbrev => 'XDDT'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 3}, {:at => Time.utc(2000, 2, 1), :offset_index => 2}, {:at => Time.utc(2000, 3, 1), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/DoubleDaylight', path) assert_equal('Zone/DoubleDaylight', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(2000, 1, 1), info) assert_period(:XDDT, 3600, 7200, true, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info) assert_period(:XDT, 3600, 3600, true, Time.utc(2000, 2, 1), Time.utc(2000, 3, 1), info) assert_period(:XST, 3600, 0, false, Time.utc(2000, 3, 1), nil, info) end end def test_load_starts_all_same_dst_offset # The zoneinfo files don't include the offset from standard time, so this # has to be derived by looking at changes in the total UTC offset. # # If there are no changes in the UTC offset (ignoring the first offset, # which is usually local mean time), then a value of 1 hour is used as the # standard time offset. offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 7200, :isdst => true, :abbrev => 'XDDT'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/DoubleDaylight', path) assert_equal('Zone/DoubleDaylight', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(2000, 1, 1), info) assert_period(:XDDT, 3600, 3600, true, Time.utc(2000, 1, 1), nil, info) end end def test_load_switch_to_dst_and_change_utc_offset # The zoneinfo files don't include the offset from standard time, so this # has to be derived by looking at changes in the total UTC offset. # Switch from non-DST to DST at the same time as moving the UTC offset # back an hour (i.e. wall clock time doesn't change). offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'YST'}, {:gmtoff => 3600, :isdst => true, :abbrev => 'XDT'}] transitions = [ {:at => Time.utc(2000, 1, 1), :offset_index => 1}, {:at => Time.utc(2000, 2, 1), :offset_index => 2}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/DoubleDaylight', path) assert_equal('Zone/DoubleDaylight', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(2000, 1, 1), info) assert_period(:YST, 3600, 0, false, Time.utc(2000, 1, 1), Time.utc(2000, 2, 1), info) assert_period(:XDT, 0, 3600, true, Time.utc(2000, 2, 1), nil, info) end end def test_load_in_safe_mode offsets = [{:gmtoff => -12094, :isdst => false, :abbrev => 'LT'}] tzif_test(offsets, []) do |path, format| # untaint only required for Ruby 1.9.2 path.untaint safe_test do info = ZoneinfoTimezoneInfo.new('Zone/three', path) assert_equal('Zone/three', info.identifier) assert_period(:LT, -12094, 0, false, nil, nil, info) end end end def test_load_encoding # tzfile.5 doesn't specify an encoding, but the source data is in ASCII. # ZoneinfoTimezoneInfo will load as UTF-8 (a superset of ASCII). offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST©'}] transitions = [ {:at => Time.utc(1971, 1, 2), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/One', path) assert_equal('Zone/One', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(1971, 1, 2), info) assert_period(:"XST©", 3600, 0, false, Time.utc(1971, 1, 2), nil, info) end end def test_load_binmode offsets = [ {:gmtoff => 3542, :isdst => false, :abbrev => 'LMT'}, {:gmtoff => 3600, :isdst => false, :abbrev => 'XST'}] # Transition time that includes CRLF (4EFF0D0A). # Test that this doesn't get corrupted by translating CRLF to LF. transitions = [ {:at => Time.utc(2011, 12, 31, 13, 24, 26), :offset_index => 1}] tzif_test(offsets, transitions) do |path, format| info = ZoneinfoTimezoneInfo.new('Zone/One', path) assert_equal('Zone/One', info.identifier) assert_period(:LMT, 3542, 0, false, nil, Time.utc(2011, 12, 31, 13, 24, 26), info) assert_period(:XST, 3600, 0, false, Time.utc(2011, 12, 31, 13, 24, 26), nil, info) end end end tzinfo-1.2.2/test/tc_timezone_index_definition.rb0000644000004100000410000000477412400401360022302 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneIndexDefinition < Minitest::Test module TimezonesTest1 include TimezoneIndexDefinition timezone 'Test/One' timezone 'Test/Two' linked_timezone 'Test/Three' timezone 'Another/Zone' linked_timezone 'And/Yet/Another' end module TimezonesTest2 include TimezoneIndexDefinition timezone 'Test/A/One' timezone 'Test/A/Two' timezone 'Test/A/Three' end module TimezonesTest3 include TimezoneIndexDefinition linked_timezone 'Test/B/One' linked_timezone 'Test/B/Two' linked_timezone 'Test/B/Three' end module TimezonesTest4 include TimezoneIndexDefinition end def test_timezones assert_equal(['Test/One', 'Test/Two', 'Test/Three', 'Another/Zone', 'And/Yet/Another'], TimezonesTest1.timezones) assert_equal(['Test/A/One', 'Test/A/Two', 'Test/A/Three'], TimezonesTest2.timezones) assert_equal(['Test/B/One', 'Test/B/Two', 'Test/B/Three'], TimezonesTest3.timezones) assert_equal([], TimezonesTest4.timezones) assert_equal(true, TimezonesTest1.timezones.frozen?) assert_equal(true, TimezonesTest2.timezones.frozen?) assert_equal(true, TimezonesTest3.timezones.frozen?) assert_equal(true, TimezonesTest4.timezones.frozen?) end def test_data_timezones assert_equal(['Test/One', 'Test/Two', 'Another/Zone'], TimezonesTest1.data_timezones) assert_equal(['Test/A/One', 'Test/A/Two', 'Test/A/Three'], TimezonesTest2.data_timezones) assert_equal([], TimezonesTest3.data_timezones) assert_equal([], TimezonesTest4.data_timezones) assert_equal(true, TimezonesTest1.data_timezones.frozen?) assert_equal(true, TimezonesTest2.data_timezones.frozen?) assert_equal(true, TimezonesTest3.data_timezones.frozen?) assert_equal(true, TimezonesTest4.data_timezones.frozen?) end def test_linked_timezones assert_equal(['Test/Three', 'And/Yet/Another'], TimezonesTest1.linked_timezones) assert_equal([], TimezonesTest2.linked_timezones) assert_equal(['Test/B/One', 'Test/B/Two', 'Test/B/Three'], TimezonesTest3.linked_timezones) assert_equal([], TimezonesTest4.linked_timezones) assert_equal(true, TimezonesTest1.linked_timezones.frozen?) assert_equal(true, TimezonesTest2.linked_timezones.frozen?) assert_equal(true, TimezonesTest3.linked_timezones.frozen?) assert_equal(true, TimezonesTest4.linked_timezones.frozen?) end end tzinfo-1.2.2/test/tc_linked_timezone.rb0000644000004100000410000001140112400401360020212 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCLinkedTimezone < Minitest::Test class TestTimezone < Timezone attr_reader :utc_period attr_reader :local_periods attr_reader :up_to_transitions attr_reader :utc attr_reader :local attr_reader :utc_to attr_reader :utc_from def self.new(identifier, no_local_periods = false) tz = super() tz.send(:setup, identifier, no_local_periods) tz end def identifier @identifier end def period_for_utc(utc) @utc = utc @utc_period end def periods_for_local(local) @local = local raise PeriodNotFound if @no_local_periods @local_periods end def transitions_up_to(utc_to, utc_from = nil) @utc_to = utc_to @utc_from = utc_from @up_to_transitions end def canonical_zone self end private def setup(identifier, no_local_periods) @identifier = identifier @no_local_periods = no_local_periods # Don't have to be real TimezonePeriod or TimezoneTransition objects # (nothing will use them). @utc_period = Object.new @local_periods = [Object.new, Object.new] @up_to_transitions = [Object.new, Object.new] end end def setup # Redefine Timezone.get to return a fake timezone. # Use without_warnings to suppress redefined get method warning. without_warnings do def Timezone.get(identifier) raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier == 'Invalid/Identifier' @timezones ||= {} @timezones[identifier] ||= identifier == 'Test/Recursive/Linked' ? LinkedTimezone.new(LinkedTimezoneInfo.new(identifier, 'Test/Recursive/Data')) : TestTimezone.new(identifier, identifier == 'Test/No/Local') end end end def teardown # Re-require timezone to reset. # Suppress redefined method warnings. without_warnings do load 'tzinfo/timezone.rb' end end def test_identifier tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked')) assert_equal('Test/Zone', tz.identifier) end def test_invalid_linked_identifier assert_raises(InvalidTimezoneIdentifier) { LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Invalid/Identifier')) } end def test_period_for_utc tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked')) linked_tz = Timezone.get('Test/Linked') t = Time.utc(2006, 6, 27, 23, 12, 28) assert_same(linked_tz.utc_period, tz.period_for_utc(t)) assert_same(t, linked_tz.utc) end def test_periods_for_local tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked')) linked_tz = Timezone.get('Test/Linked') t = Time.utc(2006, 6, 27, 23, 12, 28) assert_same(linked_tz.local_periods, tz.periods_for_local(t)) assert_same(t, linked_tz.local) end def test_periods_for_local_not_found tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/No/Local')) linked_tz = Timezone.get('Test/No/Local') t = Time.utc(2006, 6, 27, 23, 12, 28) assert_raises(PeriodNotFound) { tz.periods_for_local(t) } assert_same(t, linked_tz.local) end def test_transitions_up_to tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked')) linked_tz = Timezone.get('Test/Linked') utc_to = Time.utc(2013, 1, 1, 0, 0, 0) utc_from = Time.utc(2012, 1, 1, 0, 0, 0) assert_same(linked_tz.up_to_transitions, tz.transitions_up_to(utc_to, utc_from)) assert_same(utc_to, linked_tz.utc_to) assert_same(utc_from, linked_tz.utc_from) end def test_canonical_identifier tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked')) assert_equal('Test/Linked', tz.canonical_identifier) end def test_canonical_identifier_recursive # Recursive links are not currently used in the Time Zone database, but # will be supported by TZInfo. tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Recursive/Linked')) assert_equal('Test/Recursive/Data', tz.canonical_identifier) end def test_canonical_zone tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Linked')) linked_tz = Timezone.get('Test/Linked') assert_same(linked_tz, tz.canonical_zone) end def test_canonical_zone_recursive # Recursive links are not currently used in the Time Zone database, but # will be supported by TZInfo. tz = LinkedTimezone.new(LinkedTimezoneInfo.new('Test/Zone', 'Test/Recursive/Linked')) linked_tz = Timezone.get('Test/Recursive/Data') assert_same(linked_tz, tz.canonical_zone) end end tzinfo-1.2.2/test/tc_timezone_melbourne.rb0000644000004100000410000002414012400401360020740 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneMelbourne < Minitest::Test def test_2004 #Australia/Melbourne Sat Mar 27 15:59:59 2004 UTC = Sun Mar 28 02:59:59 2004 AEDT isdst=1 gmtoff=39600 #Australia/Melbourne Sat Mar 27 16:00:00 2004 UTC = Sun Mar 28 02:00:00 2004 AEST isdst=0 gmtoff=36000 #Australia/Melbourne Sat Oct 30 15:59:59 2004 UTC = Sun Oct 31 01:59:59 2004 AEST isdst=0 gmtoff=36000 #Australia/Melbourne Sat Oct 30 16:00:00 2004 UTC = Sun Oct 31 03:00:00 2004 AEDT isdst=1 gmtoff=39600 tz = Timezone.get('Australia/Melbourne') assert_equal(DateTime.new(2004,3,28,2,59,59), tz.utc_to_local(DateTime.new(2004,3,27,15,59,59))) assert_equal(DateTime.new(2004,3,28,2,0,0), tz.utc_to_local(DateTime.new(2004,3,27,16,0,0))) assert_equal(DateTime.new(2004,10,31,1,59,59), tz.utc_to_local(DateTime.new(2004,10,30,15,59,59))) assert_equal(DateTime.new(2004,10,31,3,0,0), tz.utc_to_local(DateTime.new(2004,10,30,16,0,0))) assert_equal(DateTime.new(2004,3,27,15,59,59), tz.local_to_utc(DateTime.new(2004,3,28,2,59,59), true)) assert_equal(DateTime.new(2004,3,27,16,59,59), tz.local_to_utc(DateTime.new(2004,3,28,2,59,59), false)) assert_equal(DateTime.new(2004,3,27,15,0,0), tz.local_to_utc(DateTime.new(2004,3,28,2,0,0), true)) assert_equal(DateTime.new(2004,3,27,16,0,0), tz.local_to_utc(DateTime.new(2004,3,28,2,0,0), false)) assert_equal(DateTime.new(2004,10,30,15,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59))) assert_equal(DateTime.new(2004,10,30,16,0,0), tz.local_to_utc(DateTime.new(2004,10,31,3,0,0))) assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,10,31,2,0,0)) } assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,3,28,2,0,0)) } assert_equal(:AEDT, tz.period_for_utc(DateTime.new(2004,3,27,15,59,59)).zone_identifier) assert_equal(:AEST, tz.period_for_utc(DateTime.new(2004,3,27,16,0,0)).zone_identifier) assert_equal(:AEST, tz.period_for_utc(DateTime.new(2004,10,30,15,59,59)).zone_identifier) assert_equal(:AEDT, tz.period_for_utc(DateTime.new(2004,10,30,16,0,0)).zone_identifier) assert_equal(:AEDT, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), true).zone_identifier) assert_equal(:AEST, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), false).zone_identifier) assert_equal(:AEDT, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), true).zone_identifier) assert_equal(:AEST, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), false).zone_identifier) assert_equal(:AEST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).zone_identifier) assert_equal(:AEDT, tz.period_for_local(DateTime.new(2004,10,31,3,0,0)).zone_identifier) assert_equal(39600, tz.period_for_utc(DateTime.new(2004,3,27,15,59,59)).utc_total_offset) assert_equal(36000, tz.period_for_utc(DateTime.new(2004,3,27,16,0,0)).utc_total_offset) assert_equal(36000, tz.period_for_utc(DateTime.new(2004,10,30,15,59,59)).utc_total_offset) assert_equal(39600, tz.period_for_utc(DateTime.new(2004,10,30,16,0,0)).utc_total_offset) assert_equal(39600, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), true).utc_total_offset) assert_equal(36000, tz.period_for_local(DateTime.new(2004,3,28,2,59,59), false).utc_total_offset) assert_equal(39600, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), true).utc_total_offset) assert_equal(36000, tz.period_for_local(DateTime.new(2004,3,28,2,0,0), false).utc_total_offset) assert_equal(36000, tz.period_for_local(DateTime.new(2004,10,31,1,59,59)).utc_total_offset) assert_equal(39600, tz.period_for_local(DateTime.new(2004,10,31,3,0,0)).utc_total_offset) transitions = tz.transitions_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0)) assert_equal(2, transitions.length) assert_equal(TimeOrDateTime.new(DateTime.new(2004,3,27,16,0,0)), transitions[0].at) assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[0].previous_offset) assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[0].offset) assert_equal(TimeOrDateTime.new(DateTime.new(2004,10,30,16,0,0)), transitions[1].at) assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[1].previous_offset) assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[1].offset) offsets = tz.offsets_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0)) assert_array_same_items([TimezoneOffset.new(36000, 0, :AEST), TimezoneOffset.new(36000, 3600, :AEDT)], offsets) end def test_1942 # This test cannot be run when using ZoneinfoDataSource on platforms # that don't support Times before the epoch (i.e. Ruby < 1.9 on Windows) # because it relates to the year 1942. if !DataSource.get.kind_of?(ZoneinfoDataSource) || RubyCoreSupport.time_supports_negative #Australia/Melbourne Sat Mar 28 14:59:59 1942 UTC = Sun Mar 29 01:59:59 1942 AEDT isdst=1 gmtoff=39600 #Australia/Melbourne Sat Mar 28 15:00:00 1942 UTC = Sun Mar 29 01:00:00 1942 AEST isdst=0 gmtoff=36000 #Australia/Melbourne Sat Sep 26 15:59:59 1942 UTC = Sun Sep 27 01:59:59 1942 AEST isdst=0 gmtoff=36000 #Australia/Melbourne Sat Sep 26 16:00:00 1942 UTC = Sun Sep 27 03:00:00 1942 AEDT isdst=1 gmtoff=39600 tz = Timezone.get('Australia/Melbourne') assert_equal(DateTime.new(1942,3,29,1,59,59), tz.utc_to_local(DateTime.new(1942,3,28,14,59,59))) assert_equal(DateTime.new(1942,3,29,1,0,0), tz.utc_to_local(DateTime.new(1942,3,28,15,0,0))) assert_equal(DateTime.new(1942,9,27,1,59,59), tz.utc_to_local(DateTime.new(1942,9,26,15,59,59))) assert_equal(DateTime.new(1942,9,27,3,0,0), tz.utc_to_local(DateTime.new(1942,9,26,16,0,0))) assert_equal(DateTime.new(1942,3,28,14,59,59), tz.local_to_utc(DateTime.new(1942,3,29,1,59,59), true)) assert_equal(DateTime.new(1942,3,28,15,59,59), tz.local_to_utc(DateTime.new(1942,3,29,1,59,59), false)) assert_equal(DateTime.new(1942,3,28,14,0,0), tz.local_to_utc(DateTime.new(1942,3,29,1,0,0), true)) assert_equal(DateTime.new(1942,3,28,15,0,0), tz.local_to_utc(DateTime.new(1942,3,29,1,0,0), false)) assert_equal(DateTime.new(1942,9,26,15,59,59), tz.local_to_utc(DateTime.new(1942,9,27,1,59,59))) assert_equal(DateTime.new(1942,9,26,16,0,0), tz.local_to_utc(DateTime.new(1942,9,27,3,0,0))) assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1942,9,27,2,0,0)) } assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1942,3,29,1,0,0)) } assert_equal(:AEDT, tz.period_for_utc(DateTime.new(1942,3,28,14,59,59)).zone_identifier) assert_equal(:AEST, tz.period_for_utc(DateTime.new(1942,3,28,15,0,0)).zone_identifier) assert_equal(:AEST, tz.period_for_utc(DateTime.new(1942,9,26,15,59,59)).zone_identifier) assert_equal(:AEDT, tz.period_for_utc(DateTime.new(1942,9,26,16,0,0)).zone_identifier) assert_equal(:AEDT, tz.period_for_local(DateTime.new(1942,3,29,1,59,59), true).zone_identifier) assert_equal(:AEST, tz.period_for_local(DateTime.new(1942,3,29,1,59,59), false).zone_identifier) assert_equal(:AEDT, tz.period_for_local(DateTime.new(1942,3,29,1,0,0), true).zone_identifier) assert_equal(:AEST, tz.period_for_local(DateTime.new(1942,3,29,1,0,0), false).zone_identifier) assert_equal(:AEST, tz.period_for_local(DateTime.new(1942,9,27,1,59,59)).zone_identifier) assert_equal(:AEDT, tz.period_for_local(DateTime.new(1942,9,27,3,0,0)).zone_identifier) assert_equal(39600, tz.period_for_utc(DateTime.new(1942,3,28,14,59,59)).utc_total_offset) assert_equal(36000, tz.period_for_utc(DateTime.new(1942,3,28,15,0,0)).utc_total_offset) assert_equal(36000, tz.period_for_utc(DateTime.new(1942,9,26,15,59,59)).utc_total_offset) assert_equal(39600, tz.period_for_utc(DateTime.new(1942,9,26,16,0,0)).utc_total_offset) assert_equal(39600, tz.period_for_local(DateTime.new(1942,3,29,1,59,59), true).utc_total_offset) assert_equal(36000, tz.period_for_local(DateTime.new(1942,3,29,1,59,59), false).utc_total_offset) assert_equal(39600, tz.period_for_local(DateTime.new(1942,3,29,1,0,0), true).utc_total_offset) assert_equal(36000, tz.period_for_local(DateTime.new(1942,3,29,1,0,0), false).utc_total_offset) assert_equal(36000, tz.period_for_local(DateTime.new(1942,9,27,1,59,59)).utc_total_offset) assert_equal(39600, tz.period_for_local(DateTime.new(1942,9,27,3,0,0)).utc_total_offset) transitions = tz.transitions_up_to(DateTime.new(1943,1,1,0,0,0), DateTime.new(1942,1,1,0,0,0)) assert_equal(2, transitions.length) assert_equal(TimeOrDateTime.new(DateTime.new(1942,3,28,15,0,0)), transitions[0].at) assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[0].previous_offset) assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[0].offset) assert_equal(TimeOrDateTime.new(DateTime.new(1942,9,26,16,0,0)), transitions[1].at) assert_equal(TimezoneOffset.new(36000, 0, :AEST), transitions[1].previous_offset) assert_equal(TimezoneOffset.new(36000, 3600, :AEDT), transitions[1].offset) offsets = tz.offsets_up_to(DateTime.new(1943,1,1,0,0,0), DateTime.new(1942,1,1,0,0,0)) assert_array_same_items([TimezoneOffset.new(36000, 0, :AEST), TimezoneOffset.new(36000, 3600, :AEDT)], offsets) end end def test_time_boundary #Australia/Melbourne Sat Mar 25 15:00:00 1944 UTC = Sun Mar 26 01:00:00 1944 AEST isdst=0 gmtoff=36000 #Australia/Melbourne Sat Oct 30 15:59:59 1971 UTC = Sun Oct 31 01:59:59 1971 AEST isdst=0 gmtoff=36000 tz = Timezone.get('Australia/Melbourne') assert_equal(DateTime.new(1970,1,1,10,0,0), tz.utc_to_local(DateTime.new(1970,1,1,0,0,0))) assert_equal(DateTime.new(1970,1,1,0,0,0), tz.local_to_utc(DateTime.new(1970,1,1,10,0,0))) assert_equal(Time.utc(1970,1,1,10,0,0), tz.utc_to_local(Time.utc(1970,1,1,0,0,0))) assert_equal(Time.utc(1970,1,1,0,0,0), tz.local_to_utc(Time.utc(1970,1,1,10,0,0))) assert_equal(36000, tz.utc_to_local(0)) assert_equal(0, tz.local_to_utc(36000)) end end tzinfo-1.2.2/test/tc_time_or_datetime.rb0000644000004100000410000012353412400401360020357 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') require 'rational' unless defined?(Rational) include TZInfo class TCTimeOrDateTime < Minitest::Test def test_initialize_time assert_nothing_raised do TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) end end def test_initialize_time_local tdt = TimeOrDateTime.new(Time.local(2006, 3, 24, 15, 32, 3)) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), tdt.to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), tdt.to_orig) assert(tdt.to_time.utc?) assert(tdt.to_orig.utc?) end def test_intialize_time_local_usec tdt = TimeOrDateTime.new(Time.local(2006, 3, 24, 15, 32, 3, 721123)) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123), tdt.to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123), tdt.to_orig) assert(tdt.to_time.utc?) assert(tdt.to_orig.utc?) end if Time.utc(2013, 1, 1).respond_to?(:nsec) def test_initialize_time_local_nsec tdt = TimeOrDateTime.new(Time.local(2006, 3, 24, 15, 32, 3, 721123 + Rational(456,1000))) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123 + Rational(456,1000)), tdt.to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123 + Rational(456,1000)), tdt.to_orig) assert(tdt.to_time.utc?) assert(tdt.to_orig.utc?) end end def test_initialize_time_utc_local # Check that local Time instances on systems using UTC as the system # time zone are still converted to UTC Time instances. # Note that this will only test will only work correctly on platforms where # setting the TZ environment variable has an effect. If setting TZ has no # effect, then this test will still pass. old_tz = ENV['TZ'] begin ENV['TZ'] = 'UTC' tdt = TimeOrDateTime.new(Time.local(2014, 1, 11, 17, 18, 41)) assert_equal(Time.utc(2014, 1, 11, 17, 18, 41), tdt.to_time) assert_equal(Time.utc(2014, 1, 11, 17, 18, 41), tdt.to_orig) assert(tdt.to_time.utc?) assert(tdt.to_orig.utc?) ensure ENV['TZ'] = old_tz end end def test_initialize_datetime_offset tdt = TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3).new_offset(Rational(5, 24))) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), tdt.to_datetime) assert_equal(0, tdt.to_datetime.offset) end def test_initialize_datetime assert_nothing_raised do TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) end end def test_initialize_timestamp assert_nothing_raised do TimeOrDateTime.new(1143214323) end end def test_initialize_timestamp_string assert_nothing_raised do TimeOrDateTime.new('1143214323') end end unless RubyCoreSupport.time_supports_64bit # Only define this test for non-64bit platforms. Some 64-bit Rubies support # greater than 64-bit, others support less than the full range. In either # case, times at the far ends of the range are so far in the future or past # that they are not going to turn up in timezone data. def test_initialize_timestamp_supported_range assert_equal((2 ** 31) - 1, TimeOrDateTime.new((2 ** 31) - 1).to_orig) assert_raises(RangeError) do TimeOrDateTime.new(2 ** 31) end if RubyCoreSupport.time_supports_negative assert_equal(-(2 ** 31), TimeOrDateTime.new(-(2 ** 31)).to_orig) assert_raises(RangeError) do TimeOrDateTime.new(-(2 ** 31) - 1) end else assert_equal(0, TimeOrDateTime.new(0).to_orig) assert_raises(RangeError) do TimeOrDateTime.new(-1) end end end end def test_to_time assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721123)).to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721123, 1000000))).to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(1143214323).to_time) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new('1143214323').to_time) end def test_to_time_trunc_to_usec assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721123), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(7211239, 10000000))).to_time) end def test_to_datetime assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).to_datetime) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721123, 1000000)), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721123)).to_datetime) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721123, 1000000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721123, 1000000))).to_datetime) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).to_datetime) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(1143214323).to_datetime) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new('1143214323').to_datetime) end def test_to_datetime_ruby186_bug # DateTime.new in Ruby 1.8.6 won't allow a time to be specified using # fractions of a second that is within the 60th second of a minute. # TimeOrDateTime has a workaround for this issue. assert_equal(DateTime.new(2006, 3, 24, 15, 32, 59) + Rational(721123, 86400000000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 59, 721123)).to_datetime) end def test_to_datetime_trunc_to_usec assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721123, 1000000)), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721123 + Rational(9, 10))).to_datetime) end def test_to_i assert_equal(1143214323, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).to_i) assert_equal(1143214323, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).to_i) assert_equal(1143214323, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).to_i) assert_equal(1143214323, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).to_i) assert_equal(1143214323, TimeOrDateTime.new(1143214323).to_i) assert_equal(1143214323, TimeOrDateTime.new('1143214323').to_i) end def test_to_orig assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).to_orig) assert_equal(1143214323, TimeOrDateTime.new(1143214323).to_orig) assert_equal(1143214323, TimeOrDateTime.new('1143214323').to_orig) end def test_to_s assert_equal("Time: #{Time.utc(2006, 3, 24, 15, 32, 3).to_s}", TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).to_s) assert_equal("DateTime: #{DateTime.new(2006, 3, 24, 15, 32, 3)}", TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).to_s) assert_equal('Timestamp: 1143214323', TimeOrDateTime.new(1143214323).to_s) assert_equal('Timestamp: 1143214323', TimeOrDateTime.new('1143214323').to_s) end def test_year assert_equal(2006, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).year) assert_equal(2006, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).year) assert_equal(2006, TimeOrDateTime.new(1143214323).year) end def test_mon assert_equal(3, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).mon) assert_equal(3, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).mon) assert_equal(3, TimeOrDateTime.new(1143214323).mon) end def test_month assert_equal(3, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).month) assert_equal(3, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).month) assert_equal(3, TimeOrDateTime.new(1143214323).month) end def test_mday assert_equal(24, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).mday) assert_equal(24, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).mday) assert_equal(24, TimeOrDateTime.new(1143214323).mday) end def test_day assert_equal(24, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).day) assert_equal(24, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).day) assert_equal(24, TimeOrDateTime.new(1143214323).day) end def test_hour assert_equal(15, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).hour) assert_equal(15, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).hour) assert_equal(15, TimeOrDateTime.new(1143214323).hour) end def test_min assert_equal(32, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).min) assert_equal(32, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).min) assert_equal(32, TimeOrDateTime.new(1143214323).min) end def test_sec assert_equal(3, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).sec) assert_equal(3, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).sec) assert_equal(3, TimeOrDateTime.new(1143214323).sec) end def test_usec assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).usec) assert_equal(721123, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721123)).usec) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).usec) assert_equal(721123, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721123,1000000))).usec) assert_equal(0, TimeOrDateTime.new(1143214323).usec) end def test_usec_after_to_i val = TimeOrDateTime.new(Time.utc(2013, 2, 4, 22, 10, 33, 598000)) assert_equal(Time.utc(2013, 2, 4, 22, 10, 33).to_i, val.to_i) assert_equal(598000, val.usec) end def test_compare_timeordatetime_time assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 4))) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2007, 3, 24, 15, 32, 3))) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 2))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2005, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 4))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2007, 3, 24, 15, 32, 3))) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 2))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2005, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 4))) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(Time.utc(2007, 3, 24, 15, 32, 3))) assert_equal(0, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 2))) assert_equal(1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(Time.utc(2005, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500001))) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 499999))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000 + DATETIME_RESOLUTION))) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000 - DATETIME_RESOLUTION))) end def test_compare_timeordatetime_datetime assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 4))) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3))) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 2))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 4))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3))) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 2))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 4))) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3))) assert_equal(0, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3))) assert_equal(1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 2))) assert_equal(1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3))) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 + DATETIME_RESOLUTION, 1000000)))) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000)))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 - DATETIME_RESOLUTION, 1000000)))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 + DATETIME_RESOLUTION, 1000000)))) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000)))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 - DATETIME_RESOLUTION, 1000000)))) end def test_compare_timeordatetime_timestamp assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214324)) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1174750323)) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214323)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214322)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1111678323)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214324)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1174750323)) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214323)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214322)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1111678323)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214323)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> TimeOrDateTime.new(1143214323)) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(1143214324)) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(1174750323)) assert_equal(0, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(1143214323)) assert_equal(1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(1143214322)) assert_equal(1, TimeOrDateTime.new(1143214323) <=> TimeOrDateTime.new(1111678323)) end def test_compare_time assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 4)) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2007, 3, 24, 15, 32, 3)) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 2)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2005, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 4)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2007, 3, 24, 15, 32, 3)) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 2)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> Time.utc(2005, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> Time.utc(2006, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> Time.utc(2006, 3, 24, 15, 32, 4)) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> Time.utc(2007, 3, 24, 15, 32, 3)) assert_equal(0, TimeOrDateTime.new(1143214323) <=> Time.utc(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(1143214323) <=> Time.utc(2006, 3, 24, 15, 32, 2)) assert_equal(1, TimeOrDateTime.new(1143214323) <=> Time.utc(2005, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> Time.utc(2006, 3, 24, 15, 32, 3, 500001)) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> Time.utc(2006, 3, 24, 15, 32, 3, 500000)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> Time.utc(2006, 3, 24, 15, 32, 3, 499999)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> Time.utc(2006, 3, 24, 15, 32, 3, 500000 + DATETIME_RESOLUTION)) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> Time.utc(2006, 3, 24, 15, 32, 3, 500000)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> Time.utc(2006, 3, 24, 15, 32, 3, 500000 - DATETIME_RESOLUTION)) end def test_compare_datetime assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 4)) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2040, 3, 24, 15, 32, 3)) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 2)) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(1960, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 4)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2040, 3, 24, 15, 32, 3)) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 2)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> DateTime.new(1960, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> DateTime.new(2006, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> DateTime.new(2006, 3, 24, 15, 32, 4)) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> DateTime.new(2040, 3, 24, 15, 32, 3)) assert_equal(0, TimeOrDateTime.new(1143214323) <=> DateTime.new(2006, 3, 24, 15, 32, 3)) assert_equal(1, TimeOrDateTime.new(1143214323) <=> DateTime.new(2006, 3, 24, 15, 32, 2)) assert_equal(1, TimeOrDateTime.new(1143214323) <=> DateTime.new(1960, 3, 24, 15, 32, 3)) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 + DATETIME_RESOLUTION, 1000000))) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 500000)) <=> DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 - DATETIME_RESOLUTION, 1000000))) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 + DATETIME_RESOLUTION, 1000000))) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000, 1000000))) <=> DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(500000 - DATETIME_RESOLUTION, 1000000))) end def test_compare_timestamp assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> 1143214324) assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> 1174750323) assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> 1143214323) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> 1143214322) assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> 1111678323) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> 1143214324) assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> 1174750323) assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> 1143214323) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> 1143214322) assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> 1111678323) assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> 1143214323) assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> 1143214323) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> 1143214324) assert_equal(-1, TimeOrDateTime.new(1143214323) <=> 1174750323) assert_equal(0, TimeOrDateTime.new(1143214323) <=> 1143214323) assert_equal(1, TimeOrDateTime.new(1143214323) <=> 1143214322) assert_equal(1, TimeOrDateTime.new(1143214323) <=> 1111678323) end def test_compare_timestamp_str assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> '1143214324') assert_equal(-1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> '1174750323') assert_equal(0, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> '1143214323') assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> '1143214322') assert_equal(1, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> '1111678323') assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> '1143214324') assert_equal(-1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> '1174750323') assert_equal(0, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> '1143214323') assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> '1143214322') assert_equal(1, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> '1111678323') assert_equal(-1, TimeOrDateTime.new(DateTime.new(1960, 3, 24, 15, 32, 3)) <=> '1143214323') assert_equal(1, TimeOrDateTime.new(DateTime.new(2040, 3, 24, 15, 32, 3)) <=> '1143214323') assert_equal(-1, TimeOrDateTime.new(1143214323) <=> '1143214324') assert_equal(-1, TimeOrDateTime.new(1143214323) <=> '1174750323') assert_equal(0, TimeOrDateTime.new(1143214323) <=> '1143214323') assert_equal(1, TimeOrDateTime.new(1143214323) <=> '1143214322') assert_equal(1, TimeOrDateTime.new(1143214323) <=> '1111678323') end def test_compare_non_comparable assert_nil(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) <=> Object.new) assert_nil(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) <=> Object.new) assert_nil(TimeOrDateTime.new(1143214323) <=> Object.new) end def test_eql assert_equal(true, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(1143214323))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new('1143214323'))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 4)))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).eql?(Object.new)) assert_equal(true, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 722000)))) assert_equal(false, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).eql?(Object.new)) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)))) assert_equal(true, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)))) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(1143214323))) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new('1143214323'))) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 4)))) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).eql?(Object.new)) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)))) assert_equal(true, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))))) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(722, 1000))))) assert_equal(false, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).eql?(Object.new)) assert_equal(false, TimeOrDateTime.new(1143214323).eql?(TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)))) assert_equal(false, TimeOrDateTime.new(1143214323).eql?(TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)))) assert_equal(true, TimeOrDateTime.new(1143214323).eql?(TimeOrDateTime.new(1143214323))) assert_equal(true, TimeOrDateTime.new(1143214323).eql?(TimeOrDateTime.new('1143214323'))) assert_equal(false, TimeOrDateTime.new(1143214323).eql?(TimeOrDateTime.new(1143214324))) assert_equal(false, TimeOrDateTime.new(1143214323).eql?(Object.new)) end def test_hash assert_equal(Time.utc(2006, 3, 24, 15, 32, 3).hash, TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).hash) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3).hash, TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).hash) assert_equal(1143214323.hash, TimeOrDateTime.new(1143214323).hash) assert_equal(1143214323.hash, TimeOrDateTime.new('1143214323').hash) end def test_add assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + 0).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + 0).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + 0).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + 0).to_orig) assert_equal(1143214323, (TimeOrDateTime.new(1143214323) + 0).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + 1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + 1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + 1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + 1).to_orig) assert_equal(1143214324, (TimeOrDateTime.new(1143214323) + 1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) + (-1)).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) + (-1)).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) + (-1)).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) + (-1)).to_orig) assert_equal(1143214322, (TimeOrDateTime.new(1143214323) + (-1)).to_orig) end def test_subtract assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - 0).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - 0).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - 0).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - 0).to_orig) assert_equal(1143214323, (TimeOrDateTime.new(1143214323) - 0).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - 1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - 1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - 1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - 1).to_orig) assert_equal(1143214322, (TimeOrDateTime.new(1143214323) - 1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)) - (-1)).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), (TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)) - (-1)).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)) - (-1)).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), (TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))) - (-1)).to_orig) assert_equal(1143214324, (TimeOrDateTime.new(1143214323) - (-1)).to_orig) end def test_add_with_convert assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(0).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(0).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(0).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(0).to_orig) assert_equal(1143214323, TimeOrDateTime.new(1143214323).add_with_convert(0).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 4, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(1).to_orig) assert_equal(1143214324, TimeOrDateTime.new(1143214323).add_with_convert(1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 2), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3)).add_with_convert(-1).to_orig) assert_equal(Time.utc(2006, 3, 24, 15, 32, 2, 721000), TimeOrDateTime.new(Time.utc(2006, 3, 24, 15, 32, 3, 721000)).add_with_convert(-1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3)).add_with_convert(-1).to_orig) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 2 + Rational(721, 1000)), TimeOrDateTime.new(DateTime.new(2006, 3, 24, 15, 32, 3 + Rational(721, 1000))).add_with_convert(-1).to_orig) assert_equal(1143214322, TimeOrDateTime.new(1143214323).add_with_convert(-1).to_orig) if RubyCoreSupport.time_supports_negative assert_equal(Time.utc(1969, 12, 31, 23, 59, 59), TimeOrDateTime.new(Time.utc(1970, 1, 1, 0, 0, 0)).add_with_convert(-1).to_orig) assert_equal(-1, TimeOrDateTime.new(0).add_with_convert(-1).to_orig) assert_equal(Time.utc(1969, 12, 31, 23, 59, 59, 892000), TimeOrDateTime.new(Time.utc(1970, 1, 1, 0, 0, 0, 892000)).add_with_convert(-1).to_orig) if RubyCoreSupport.time_supports_64bit assert_equal(Time.utc(1901, 12, 13, 20, 45, 51), TimeOrDateTime.new(Time.utc(1901, 12, 13, 20, 45, 52)).add_with_convert(-1).to_orig) assert_equal(-2147483649, TimeOrDateTime.new(-2147483648).add_with_convert(-1).to_orig) assert_equal(Time.utc(1901, 12, 13, 20, 45, 51, 892000), TimeOrDateTime.new(Time.utc(1901, 12, 13, 20, 45, 52, 892000)).add_with_convert(-1).to_orig) else assert_equal(DateTime.new(1901, 12, 13, 20, 45, 51), TimeOrDateTime.new(Time.utc(1901, 12, 13, 20, 45, 52)).add_with_convert(-1).to_orig) assert_equal(DateTime.new(1901, 12, 13, 20, 45, 51), TimeOrDateTime.new(-2147483648).add_with_convert(-1).to_orig) assert_equal(DateTime.new(1901, 12, 13, 20, 45, 51 + Rational(892,1000)), TimeOrDateTime.new(Time.utc(1901, 12, 13, 20, 45, 52, 892000)).add_with_convert(-1).to_orig) end else assert_equal(DateTime.new(1969, 12, 31, 23, 59, 59), TimeOrDateTime.new(Time.utc(1970, 1, 1, 0, 0, 0)).add_with_convert(-1).to_orig) assert_equal(DateTime.new(1969, 12, 31, 23, 59, 59), TimeOrDateTime.new(0).add_with_convert(-1).to_orig) assert_equal(RubyCoreSupport.datetime_new(1969, 12, 31, 23, 59, 59 + Rational(892,1000)), TimeOrDateTime.new(Time.utc(1970, 1, 1, 0, 0, 0, 892000)).add_with_convert(-1).to_orig) end if RubyCoreSupport.time_supports_64bit assert_equal(Time.utc(2038, 1, 19, 3, 14, 8), TimeOrDateTime.new(Time.utc(2038, 1, 19, 3, 14, 7)).add_with_convert(1).to_orig) assert_equal(2147483648, TimeOrDateTime.new(2147483647).add_with_convert(1).to_orig) assert_equal(Time.utc(2038, 1, 19, 3, 14, 8, 892000), TimeOrDateTime.new(Time.utc(2038, 1, 19, 3, 14, 7, 892000)).add_with_convert(1).to_orig) else assert_equal(DateTime.new(2038, 1, 19, 3, 14, 8), TimeOrDateTime.new(Time.utc(2038, 1, 19, 3, 14, 7)).add_with_convert(1).to_orig) assert_equal(DateTime.new(2038, 1, 19, 3, 14, 8), TimeOrDateTime.new(2147483647).add_with_convert(1).to_orig) assert_equal(DateTime.new(2038, 1, 19, 3, 14, 8 + Rational(892,1000)), TimeOrDateTime.new(Time.utc(2038, 1, 19, 3, 14, 7, 892000)).add_with_convert(1).to_orig) assert_equal(Time.utc(2038, 1, 19, 3, 14, 7, 892000), TimeOrDateTime.new(Time.utc(2038, 1, 19, 3, 14, 6, 892000)).add_with_convert(1).to_orig) end end def test_wrap_time t = TimeOrDateTime.wrap(Time.utc(2006, 3, 24, 15, 32, 3)) assert_instance_of(TimeOrDateTime, t) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), t.to_orig) end def test_wrap_datetime t = TimeOrDateTime.wrap(DateTime.new(2006, 3, 24, 15, 32, 3)) assert_instance_of(TimeOrDateTime, t) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), t.to_orig) end def test_wrap_timestamp t = TimeOrDateTime.wrap(1143214323) assert_instance_of(TimeOrDateTime, t) assert_equal(1143214323, t.to_orig) end def test_wrap_timestamp_str t = TimeOrDateTime.wrap('1143214323') assert_instance_of(TimeOrDateTime, t) assert_equal(1143214323, t.to_orig) end def test_wrap_timeordatetime t = TimeOrDateTime.new(1143214323) t2 = TimeOrDateTime.wrap(t) assert_same(t, t2) end def test_wrap_block_time assert_equal(Time.utc(2006, 3, 24, 15, 32, 4), TimeOrDateTime.wrap(Time.utc(2006, 3, 24, 15, 32, 3)) {|t| assert_instance_of(TimeOrDateTime, t) assert_equal(Time.utc(2006, 3, 24, 15, 32, 3), t.to_orig) t + 1 }) end def test_wrap_block_datetime assert_equal(DateTime.new(2006, 3, 24, 15, 32, 4), TimeOrDateTime.wrap(DateTime.new(2006, 3, 24, 15, 32, 3)) {|t| assert_instance_of(TimeOrDateTime, t) assert_equal(DateTime.new(2006, 3, 24, 15, 32, 3), t.to_orig) t + 1 }) end def test_wrap_block_timestamp assert_equal(1143214324, TimeOrDateTime.wrap(1143214323) {|t| assert_instance_of(TimeOrDateTime, t) assert_equal(1143214323, t.to_orig) t + 1 }) end def test_wrap_block_timestamp_str assert_equal(1143214324, TimeOrDateTime.wrap('1143214323') {|t| assert_instance_of(TimeOrDateTime, t) assert_equal(1143214323, t.to_orig) t + 1 }) end def test_wrap_block_timeordatetime t1 = TimeOrDateTime.new(1143214323) t2 = TimeOrDateTime.wrap(t1) {|t| assert_same(t1, t) t + 1 } assert t2 assert_instance_of(TimeOrDateTime, t2) assert_equal(1143214324, t2.to_orig) end end tzinfo-1.2.2/test/tc_data_timezone.rb0000644000004100000410000000561712400401360017671 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCDataTimezone < Minitest::Test class TestTimezoneInfo < TimezoneInfo attr_reader :utc attr_reader :local attr_reader :utc_to attr_reader :utc_from def initialize(identifier, utc_period, local_periods, transitions_up_to) super(identifier) @utc_period = utc_period @local_periods = local_periods || [] @transitions_up_to = transitions_up_to end def period_for_utc(utc) @utc = utc @utc_period end def periods_for_local(local) @local = local @local_periods end def transitions_up_to(utc_to, utc_from = nil) @utc_to = utc_to @utc_from = utc_from @transitions_up_to end end def test_identifier tz = DataTimezone.new(TestTimezoneInfo.new('Test/Zone', nil, [], [])) assert_equal('Test/Zone', tz.identifier) end def test_period_for_utc # Don't need actual TimezonePeriods. DataTimezone isn't supposed to do # anything with them apart from return them. period = Object.new tti = TestTimezoneInfo.new('Test/Zone', period, [], []) tz = DataTimezone.new(tti) t = Time.utc(2006, 6, 27, 22, 50, 12) assert_same(period, tz.period_for_utc(t)) assert_same(t, tti.utc) end def test_periods_for_local # Don't need actual TimezonePeriods. DataTimezone isn't supposed to do # anything with them apart from return them. periods = [Object.new, Object.new] tti = TestTimezoneInfo.new('Test/Zone', nil, periods, []) tz = DataTimezone.new(tti) t = Time.utc(2006, 6, 27, 22, 50, 12) assert_same(periods, tz.periods_for_local(t)) assert_same(t, tti.local) end def test_periods_for_local_not_found periods = [] tti = TestTimezoneInfo.new('Test/Zone', nil, periods, []) tz = DataTimezone.new(tti) t = Time.utc(2006, 6, 27, 22, 50, 12) assert_same(periods, tz.periods_for_local(t)) assert_same(t, tti.local) end def test_transitions_up_to # Don't need actual TimezoneTransition instances. DataTimezone isn't # supposed to do anything with them apart from return them. transitions = [Object.new, Object.new] tti = TestTimezoneInfo.new('Test/Zone', nil, nil, transitions) tz = DataTimezone.new(tti) utc_to = Time.utc(2013, 1, 1, 0, 0, 0) utc_from = Time.utc(2012, 1, 1, 0, 0, 0) assert_same(transitions, tz.transitions_up_to(utc_to, utc_from)) assert_same(utc_to, tti.utc_to) assert_same(utc_from, tti.utc_from) end def test_canonical_identifier tz = DataTimezone.new(TestTimezoneInfo.new('Test/Zone', nil, [], [])) assert_equal('Test/Zone', tz.canonical_identifier) end def test_canonical_zone tz = DataTimezone.new(TestTimezoneInfo.new('Test/Zone', nil, [], [])) assert_same(tz, tz.canonical_zone) end end tzinfo-1.2.2/test/tzinfo-data/0000755000004100000410000000000012400401360016242 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/0000755000004100000410000000000012400401360017553 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/0000755000004100000410000000000012400401360020464 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/0000755000004100000410000000000012400401360022777 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Europe/0000755000004100000410000000000012400401360024236 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Europe/Prague.rb0000644000004100000410000002664212400401360026020 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Europe module Prague include TimezoneDefinition timezone 'Europe/Prague' do |tz| tz.offset :o0, 3464, 0, :LMT tz.offset :o1, 3464, 0, :PMT tz.offset :o2, 3600, 0, :CET tz.offset :o3, 3600, 3600, :CEST tz.transition 1849, 12, :o1, -3786829064, 25884991367, 10800 tz.transition 1891, 9, :o2, -2469401864, 26049669767, 10800 tz.transition 1916, 4, :o3, -1693706400, 29051813, 12 tz.transition 1916, 9, :o2, -1680483600, 58107299, 24 tz.transition 1917, 4, :o3, -1663455600, 58112029, 24 tz.transition 1917, 9, :o2, -1650150000, 58115725, 24 tz.transition 1918, 4, :o3, -1632006000, 58120765, 24 tz.transition 1918, 9, :o2, -1618700400, 58124461, 24 tz.transition 1940, 4, :o3, -938905200, 58313293, 24 tz.transition 1942, 11, :o2, -857257200, 58335973, 24 tz.transition 1943, 3, :o3, -844556400, 58339501, 24 tz.transition 1943, 10, :o2, -828226800, 58344037, 24 tz.transition 1944, 4, :o3, -812502000, 58348405, 24 tz.transition 1944, 9, :o2, -798073200, 58352413, 24 tz.transition 1945, 4, :o3, -780534000, 58357285, 24 tz.transition 1945, 11, :o2, -761180400, 58362661, 24 tz.transition 1946, 5, :o3, -746578800, 58366717, 24 tz.transition 1946, 10, :o2, -733359600, 58370389, 24 tz.transition 1947, 4, :o3, -716425200, 58375093, 24 tz.transition 1947, 10, :o2, -701910000, 58379125, 24 tz.transition 1948, 4, :o3, -684975600, 58383829, 24 tz.transition 1948, 10, :o2, -670460400, 58387861, 24 tz.transition 1949, 4, :o3, -654217200, 58392373, 24 tz.transition 1949, 10, :o2, -639010800, 58396597, 24 tz.transition 1979, 4, :o3, 291776400 tz.transition 1979, 9, :o2, 307501200 tz.transition 1980, 4, :o3, 323830800 tz.transition 1980, 9, :o2, 338950800 tz.transition 1981, 3, :o3, 354675600 tz.transition 1981, 9, :o2, 370400400 tz.transition 1982, 3, :o3, 386125200 tz.transition 1982, 9, :o2, 401850000 tz.transition 1983, 3, :o3, 417574800 tz.transition 1983, 9, :o2, 433299600 tz.transition 1984, 3, :o3, 449024400 tz.transition 1984, 9, :o2, 465354000 tz.transition 1985, 3, :o3, 481078800 tz.transition 1985, 9, :o2, 496803600 tz.transition 1986, 3, :o3, 512528400 tz.transition 1986, 9, :o2, 528253200 tz.transition 1987, 3, :o3, 543978000 tz.transition 1987, 9, :o2, 559702800 tz.transition 1988, 3, :o3, 575427600 tz.transition 1988, 9, :o2, 591152400 tz.transition 1989, 3, :o3, 606877200 tz.transition 1989, 9, :o2, 622602000 tz.transition 1990, 3, :o3, 638326800 tz.transition 1990, 9, :o2, 654656400 tz.transition 1991, 3, :o3, 670381200 tz.transition 1991, 9, :o2, 686106000 tz.transition 1992, 3, :o3, 701830800 tz.transition 1992, 9, :o2, 717555600 tz.transition 1993, 3, :o3, 733280400 tz.transition 1993, 9, :o2, 749005200 tz.transition 1994, 3, :o3, 764730000 tz.transition 1994, 9, :o2, 780454800 tz.transition 1995, 3, :o3, 796179600 tz.transition 1995, 9, :o2, 811904400 tz.transition 1996, 3, :o3, 828234000 tz.transition 1996, 10, :o2, 846378000 tz.transition 1997, 3, :o3, 859683600 tz.transition 1997, 10, :o2, 877827600 tz.transition 1998, 3, :o3, 891133200 tz.transition 1998, 10, :o2, 909277200 tz.transition 1999, 3, :o3, 922582800 tz.transition 1999, 10, :o2, 941331600 tz.transition 2000, 3, :o3, 954032400 tz.transition 2000, 10, :o2, 972781200 tz.transition 2001, 3, :o3, 985482000 tz.transition 2001, 10, :o2, 1004230800 tz.transition 2002, 3, :o3, 1017536400 tz.transition 2002, 10, :o2, 1035680400 tz.transition 2003, 3, :o3, 1048986000 tz.transition 2003, 10, :o2, 1067130000 tz.transition 2004, 3, :o3, 1080435600 tz.transition 2004, 10, :o2, 1099184400 tz.transition 2005, 3, :o3, 1111885200 tz.transition 2005, 10, :o2, 1130634000 tz.transition 2006, 3, :o3, 1143334800 tz.transition 2006, 10, :o2, 1162083600 tz.transition 2007, 3, :o3, 1174784400 tz.transition 2007, 10, :o2, 1193533200 tz.transition 2008, 3, :o3, 1206838800 tz.transition 2008, 10, :o2, 1224982800 tz.transition 2009, 3, :o3, 1238288400 tz.transition 2009, 10, :o2, 1256432400 tz.transition 2010, 3, :o3, 1269738000 tz.transition 2010, 10, :o2, 1288486800 tz.transition 2011, 3, :o3, 1301187600 tz.transition 2011, 10, :o2, 1319936400 tz.transition 2012, 3, :o3, 1332637200 tz.transition 2012, 10, :o2, 1351386000 tz.transition 2013, 3, :o3, 1364691600 tz.transition 2013, 10, :o2, 1382835600 tz.transition 2014, 3, :o3, 1396141200 tz.transition 2014, 10, :o2, 1414285200 tz.transition 2015, 3, :o3, 1427590800 tz.transition 2015, 10, :o2, 1445734800 tz.transition 2016, 3, :o3, 1459040400 tz.transition 2016, 10, :o2, 1477789200 tz.transition 2017, 3, :o3, 1490490000 tz.transition 2017, 10, :o2, 1509238800 tz.transition 2018, 3, :o3, 1521939600 tz.transition 2018, 10, :o2, 1540688400 tz.transition 2019, 3, :o3, 1553994000 tz.transition 2019, 10, :o2, 1572138000 tz.transition 2020, 3, :o3, 1585443600 tz.transition 2020, 10, :o2, 1603587600 tz.transition 2021, 3, :o3, 1616893200 tz.transition 2021, 10, :o2, 1635642000 tz.transition 2022, 3, :o3, 1648342800 tz.transition 2022, 10, :o2, 1667091600 tz.transition 2023, 3, :o3, 1679792400 tz.transition 2023, 10, :o2, 1698541200 tz.transition 2024, 3, :o3, 1711846800 tz.transition 2024, 10, :o2, 1729990800 tz.transition 2025, 3, :o3, 1743296400 tz.transition 2025, 10, :o2, 1761440400 tz.transition 2026, 3, :o3, 1774746000 tz.transition 2026, 10, :o2, 1792890000 tz.transition 2027, 3, :o3, 1806195600 tz.transition 2027, 10, :o2, 1824944400 tz.transition 2028, 3, :o3, 1837645200 tz.transition 2028, 10, :o2, 1856394000 tz.transition 2029, 3, :o3, 1869094800 tz.transition 2029, 10, :o2, 1887843600 tz.transition 2030, 3, :o3, 1901149200 tz.transition 2030, 10, :o2, 1919293200 tz.transition 2031, 3, :o3, 1932598800 tz.transition 2031, 10, :o2, 1950742800 tz.transition 2032, 3, :o3, 1964048400 tz.transition 2032, 10, :o2, 1982797200 tz.transition 2033, 3, :o3, 1995498000 tz.transition 2033, 10, :o2, 2014246800 tz.transition 2034, 3, :o3, 2026947600 tz.transition 2034, 10, :o2, 2045696400 tz.transition 2035, 3, :o3, 2058397200 tz.transition 2035, 10, :o2, 2077146000 tz.transition 2036, 3, :o3, 2090451600 tz.transition 2036, 10, :o2, 2108595600 tz.transition 2037, 3, :o3, 2121901200 tz.transition 2037, 10, :o2, 2140045200 tz.transition 2038, 3, :o3, 2153350800, 59172253, 24 tz.transition 2038, 10, :o2, 2172099600, 59177461, 24 tz.transition 2039, 3, :o3, 2184800400, 59180989, 24 tz.transition 2039, 10, :o2, 2203549200, 59186197, 24 tz.transition 2040, 3, :o3, 2216250000, 59189725, 24 tz.transition 2040, 10, :o2, 2234998800, 59194933, 24 tz.transition 2041, 3, :o3, 2248304400, 59198629, 24 tz.transition 2041, 10, :o2, 2266448400, 59203669, 24 tz.transition 2042, 3, :o3, 2279754000, 59207365, 24 tz.transition 2042, 10, :o2, 2297898000, 59212405, 24 tz.transition 2043, 3, :o3, 2311203600, 59216101, 24 tz.transition 2043, 10, :o2, 2329347600, 59221141, 24 tz.transition 2044, 3, :o3, 2342653200, 59224837, 24 tz.transition 2044, 10, :o2, 2361402000, 59230045, 24 tz.transition 2045, 3, :o3, 2374102800, 59233573, 24 tz.transition 2045, 10, :o2, 2392851600, 59238781, 24 tz.transition 2046, 3, :o3, 2405552400, 59242309, 24 tz.transition 2046, 10, :o2, 2424301200, 59247517, 24 tz.transition 2047, 3, :o3, 2437606800, 59251213, 24 tz.transition 2047, 10, :o2, 2455750800, 59256253, 24 tz.transition 2048, 3, :o3, 2469056400, 59259949, 24 tz.transition 2048, 10, :o2, 2487200400, 59264989, 24 tz.transition 2049, 3, :o3, 2500506000, 59268685, 24 tz.transition 2049, 10, :o2, 2519254800, 59273893, 24 tz.transition 2050, 3, :o3, 2531955600, 59277421, 24 tz.transition 2050, 10, :o2, 2550704400, 59282629, 24 tz.transition 2051, 3, :o3, 2563405200, 59286157, 24 tz.transition 2051, 10, :o2, 2582154000, 59291365, 24 tz.transition 2052, 3, :o3, 2595459600, 59295061, 24 tz.transition 2052, 10, :o2, 2613603600, 59300101, 24 tz.transition 2053, 3, :o3, 2626909200, 59303797, 24 tz.transition 2053, 10, :o2, 2645053200, 59308837, 24 tz.transition 2054, 3, :o3, 2658358800, 59312533, 24 tz.transition 2054, 10, :o2, 2676502800, 59317573, 24 tz.transition 2055, 3, :o3, 2689808400, 59321269, 24 tz.transition 2055, 10, :o2, 2708557200, 59326477, 24 tz.transition 2056, 3, :o3, 2721258000, 59330005, 24 tz.transition 2056, 10, :o2, 2740006800, 59335213, 24 tz.transition 2057, 3, :o3, 2752707600, 59338741, 24 tz.transition 2057, 10, :o2, 2771456400, 59343949, 24 tz.transition 2058, 3, :o3, 2784762000, 59347645, 24 tz.transition 2058, 10, :o2, 2802906000, 59352685, 24 tz.transition 2059, 3, :o3, 2816211600, 59356381, 24 tz.transition 2059, 10, :o2, 2834355600, 59361421, 24 tz.transition 2060, 3, :o3, 2847661200, 59365117, 24 tz.transition 2060, 10, :o2, 2866410000, 59370325, 24 tz.transition 2061, 3, :o3, 2879110800, 59373853, 24 tz.transition 2061, 10, :o2, 2897859600, 59379061, 24 tz.transition 2062, 3, :o3, 2910560400, 59382589, 24 tz.transition 2062, 10, :o2, 2929309200, 59387797, 24 tz.transition 2063, 3, :o3, 2942010000, 59391325, 24 tz.transition 2063, 10, :o2, 2960758800, 59396533, 24 tz.transition 2064, 3, :o3, 2974064400, 59400229, 24 tz.transition 2064, 10, :o2, 2992208400, 59405269, 24 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Europe/Amsterdam.rb0000644000004100000410000003432112400401360026503 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Europe module Amsterdam include TimezoneDefinition timezone 'Europe/Amsterdam' do |tz| tz.offset :o0, 1172, 0, :LMT tz.offset :o1, 1172, 0, :AMT tz.offset :o2, 1172, 3600, :NST tz.offset :o3, 1200, 3600, :NEST tz.offset :o4, 1200, 0, :NET tz.offset :o5, 3600, 3600, :CEST tz.offset :o6, 3600, 0, :CET tz.transition 1834, 12, :o1, -4260212372, 51651636907, 21600 tz.transition 1916, 4, :o2, -1693700372, 52293264907, 21600 tz.transition 1916, 9, :o1, -1680484772, 52296568807, 21600 tz.transition 1917, 4, :o2, -1663453172, 52300826707, 21600 tz.transition 1917, 9, :o1, -1650147572, 52304153107, 21600 tz.transition 1918, 4, :o2, -1633213172, 52308386707, 21600 tz.transition 1918, 9, :o1, -1617488372, 52312317907, 21600 tz.transition 1919, 4, :o2, -1601158772, 52316400307, 21600 tz.transition 1919, 9, :o1, -1586038772, 52320180307, 21600 tz.transition 1920, 4, :o2, -1569709172, 52324262707, 21600 tz.transition 1920, 9, :o1, -1554589172, 52328042707, 21600 tz.transition 1921, 4, :o2, -1538259572, 52332125107, 21600 tz.transition 1921, 9, :o1, -1523139572, 52335905107, 21600 tz.transition 1922, 3, :o2, -1507501172, 52339814707, 21600 tz.transition 1922, 10, :o1, -1490566772, 52344048307, 21600 tz.transition 1923, 6, :o2, -1470176372, 52349145907, 21600 tz.transition 1923, 10, :o1, -1459117172, 52351910707, 21600 tz.transition 1924, 3, :o2, -1443997172, 52355690707, 21600 tz.transition 1924, 10, :o1, -1427667572, 52359773107, 21600 tz.transition 1925, 6, :o2, -1406672372, 52365021907, 21600 tz.transition 1925, 10, :o1, -1396217972, 52367635507, 21600 tz.transition 1926, 5, :o2, -1376950772, 52372452307, 21600 tz.transition 1926, 10, :o1, -1364768372, 52375497907, 21600 tz.transition 1927, 5, :o2, -1345414772, 52380336307, 21600 tz.transition 1927, 10, :o1, -1333318772, 52383360307, 21600 tz.transition 1928, 5, :o2, -1313792372, 52388241907, 21600 tz.transition 1928, 10, :o1, -1301264372, 52391373907, 21600 tz.transition 1929, 5, :o2, -1282256372, 52396125907, 21600 tz.transition 1929, 10, :o1, -1269814772, 52399236307, 21600 tz.transition 1930, 5, :o2, -1250720372, 52404009907, 21600 tz.transition 1930, 10, :o1, -1238365172, 52407098707, 21600 tz.transition 1931, 5, :o2, -1219184372, 52411893907, 21600 tz.transition 1931, 10, :o1, -1206915572, 52414961107, 21600 tz.transition 1932, 5, :o2, -1186957172, 52419950707, 21600 tz.transition 1932, 10, :o1, -1175465972, 52422823507, 21600 tz.transition 1933, 5, :o2, -1156025972, 52427683507, 21600 tz.transition 1933, 10, :o1, -1143411572, 52430837107, 21600 tz.transition 1934, 5, :o2, -1124489972, 52435567507, 21600 tz.transition 1934, 10, :o1, -1111961972, 52438699507, 21600 tz.transition 1935, 5, :o2, -1092953972, 52443451507, 21600 tz.transition 1935, 10, :o1, -1080512372, 52446561907, 21600 tz.transition 1936, 5, :o2, -1061331572, 52451357107, 21600 tz.transition 1936, 10, :o1, -1049062772, 52454424307, 21600 tz.transition 1937, 5, :o2, -1029190772, 52459392307, 21600 tz.transition 1937, 6, :o3, -1025745572, 52460253607, 21600 tz.transition 1937, 10, :o4, -1017613200, 174874289, 72 tz.transition 1938, 5, :o3, -998259600, 174890417, 72 tz.transition 1938, 10, :o4, -986163600, 174900497, 72 tz.transition 1939, 5, :o3, -966723600, 174916697, 72 tz.transition 1939, 10, :o4, -954109200, 174927209, 72 tz.transition 1940, 5, :o5, -935022000, 174943115, 72 tz.transition 1942, 11, :o6, -857257200, 58335973, 24 tz.transition 1943, 3, :o5, -844556400, 58339501, 24 tz.transition 1943, 10, :o6, -828226800, 58344037, 24 tz.transition 1944, 4, :o5, -812502000, 58348405, 24 tz.transition 1944, 10, :o6, -796777200, 58352773, 24 tz.transition 1945, 4, :o5, -781052400, 58357141, 24 tz.transition 1945, 9, :o6, -766623600, 58361149, 24 tz.transition 1977, 4, :o5, 228877200 tz.transition 1977, 9, :o6, 243997200 tz.transition 1978, 4, :o5, 260326800 tz.transition 1978, 10, :o6, 276051600 tz.transition 1979, 4, :o5, 291776400 tz.transition 1979, 9, :o6, 307501200 tz.transition 1980, 4, :o5, 323830800 tz.transition 1980, 9, :o6, 338950800 tz.transition 1981, 3, :o5, 354675600 tz.transition 1981, 9, :o6, 370400400 tz.transition 1982, 3, :o5, 386125200 tz.transition 1982, 9, :o6, 401850000 tz.transition 1983, 3, :o5, 417574800 tz.transition 1983, 9, :o6, 433299600 tz.transition 1984, 3, :o5, 449024400 tz.transition 1984, 9, :o6, 465354000 tz.transition 1985, 3, :o5, 481078800 tz.transition 1985, 9, :o6, 496803600 tz.transition 1986, 3, :o5, 512528400 tz.transition 1986, 9, :o6, 528253200 tz.transition 1987, 3, :o5, 543978000 tz.transition 1987, 9, :o6, 559702800 tz.transition 1988, 3, :o5, 575427600 tz.transition 1988, 9, :o6, 591152400 tz.transition 1989, 3, :o5, 606877200 tz.transition 1989, 9, :o6, 622602000 tz.transition 1990, 3, :o5, 638326800 tz.transition 1990, 9, :o6, 654656400 tz.transition 1991, 3, :o5, 670381200 tz.transition 1991, 9, :o6, 686106000 tz.transition 1992, 3, :o5, 701830800 tz.transition 1992, 9, :o6, 717555600 tz.transition 1993, 3, :o5, 733280400 tz.transition 1993, 9, :o6, 749005200 tz.transition 1994, 3, :o5, 764730000 tz.transition 1994, 9, :o6, 780454800 tz.transition 1995, 3, :o5, 796179600 tz.transition 1995, 9, :o6, 811904400 tz.transition 1996, 3, :o5, 828234000 tz.transition 1996, 10, :o6, 846378000 tz.transition 1997, 3, :o5, 859683600 tz.transition 1997, 10, :o6, 877827600 tz.transition 1998, 3, :o5, 891133200 tz.transition 1998, 10, :o6, 909277200 tz.transition 1999, 3, :o5, 922582800 tz.transition 1999, 10, :o6, 941331600 tz.transition 2000, 3, :o5, 954032400 tz.transition 2000, 10, :o6, 972781200 tz.transition 2001, 3, :o5, 985482000 tz.transition 2001, 10, :o6, 1004230800 tz.transition 2002, 3, :o5, 1017536400 tz.transition 2002, 10, :o6, 1035680400 tz.transition 2003, 3, :o5, 1048986000 tz.transition 2003, 10, :o6, 1067130000 tz.transition 2004, 3, :o5, 1080435600 tz.transition 2004, 10, :o6, 1099184400 tz.transition 2005, 3, :o5, 1111885200 tz.transition 2005, 10, :o6, 1130634000 tz.transition 2006, 3, :o5, 1143334800 tz.transition 2006, 10, :o6, 1162083600 tz.transition 2007, 3, :o5, 1174784400 tz.transition 2007, 10, :o6, 1193533200 tz.transition 2008, 3, :o5, 1206838800 tz.transition 2008, 10, :o6, 1224982800 tz.transition 2009, 3, :o5, 1238288400 tz.transition 2009, 10, :o6, 1256432400 tz.transition 2010, 3, :o5, 1269738000 tz.transition 2010, 10, :o6, 1288486800 tz.transition 2011, 3, :o5, 1301187600 tz.transition 2011, 10, :o6, 1319936400 tz.transition 2012, 3, :o5, 1332637200 tz.transition 2012, 10, :o6, 1351386000 tz.transition 2013, 3, :o5, 1364691600 tz.transition 2013, 10, :o6, 1382835600 tz.transition 2014, 3, :o5, 1396141200 tz.transition 2014, 10, :o6, 1414285200 tz.transition 2015, 3, :o5, 1427590800 tz.transition 2015, 10, :o6, 1445734800 tz.transition 2016, 3, :o5, 1459040400 tz.transition 2016, 10, :o6, 1477789200 tz.transition 2017, 3, :o5, 1490490000 tz.transition 2017, 10, :o6, 1509238800 tz.transition 2018, 3, :o5, 1521939600 tz.transition 2018, 10, :o6, 1540688400 tz.transition 2019, 3, :o5, 1553994000 tz.transition 2019, 10, :o6, 1572138000 tz.transition 2020, 3, :o5, 1585443600 tz.transition 2020, 10, :o6, 1603587600 tz.transition 2021, 3, :o5, 1616893200 tz.transition 2021, 10, :o6, 1635642000 tz.transition 2022, 3, :o5, 1648342800 tz.transition 2022, 10, :o6, 1667091600 tz.transition 2023, 3, :o5, 1679792400 tz.transition 2023, 10, :o6, 1698541200 tz.transition 2024, 3, :o5, 1711846800 tz.transition 2024, 10, :o6, 1729990800 tz.transition 2025, 3, :o5, 1743296400 tz.transition 2025, 10, :o6, 1761440400 tz.transition 2026, 3, :o5, 1774746000 tz.transition 2026, 10, :o6, 1792890000 tz.transition 2027, 3, :o5, 1806195600 tz.transition 2027, 10, :o6, 1824944400 tz.transition 2028, 3, :o5, 1837645200 tz.transition 2028, 10, :o6, 1856394000 tz.transition 2029, 3, :o5, 1869094800 tz.transition 2029, 10, :o6, 1887843600 tz.transition 2030, 3, :o5, 1901149200 tz.transition 2030, 10, :o6, 1919293200 tz.transition 2031, 3, :o5, 1932598800 tz.transition 2031, 10, :o6, 1950742800 tz.transition 2032, 3, :o5, 1964048400 tz.transition 2032, 10, :o6, 1982797200 tz.transition 2033, 3, :o5, 1995498000 tz.transition 2033, 10, :o6, 2014246800 tz.transition 2034, 3, :o5, 2026947600 tz.transition 2034, 10, :o6, 2045696400 tz.transition 2035, 3, :o5, 2058397200 tz.transition 2035, 10, :o6, 2077146000 tz.transition 2036, 3, :o5, 2090451600 tz.transition 2036, 10, :o6, 2108595600 tz.transition 2037, 3, :o5, 2121901200 tz.transition 2037, 10, :o6, 2140045200 tz.transition 2038, 3, :o5, 2153350800, 59172253, 24 tz.transition 2038, 10, :o6, 2172099600, 59177461, 24 tz.transition 2039, 3, :o5, 2184800400, 59180989, 24 tz.transition 2039, 10, :o6, 2203549200, 59186197, 24 tz.transition 2040, 3, :o5, 2216250000, 59189725, 24 tz.transition 2040, 10, :o6, 2234998800, 59194933, 24 tz.transition 2041, 3, :o5, 2248304400, 59198629, 24 tz.transition 2041, 10, :o6, 2266448400, 59203669, 24 tz.transition 2042, 3, :o5, 2279754000, 59207365, 24 tz.transition 2042, 10, :o6, 2297898000, 59212405, 24 tz.transition 2043, 3, :o5, 2311203600, 59216101, 24 tz.transition 2043, 10, :o6, 2329347600, 59221141, 24 tz.transition 2044, 3, :o5, 2342653200, 59224837, 24 tz.transition 2044, 10, :o6, 2361402000, 59230045, 24 tz.transition 2045, 3, :o5, 2374102800, 59233573, 24 tz.transition 2045, 10, :o6, 2392851600, 59238781, 24 tz.transition 2046, 3, :o5, 2405552400, 59242309, 24 tz.transition 2046, 10, :o6, 2424301200, 59247517, 24 tz.transition 2047, 3, :o5, 2437606800, 59251213, 24 tz.transition 2047, 10, :o6, 2455750800, 59256253, 24 tz.transition 2048, 3, :o5, 2469056400, 59259949, 24 tz.transition 2048, 10, :o6, 2487200400, 59264989, 24 tz.transition 2049, 3, :o5, 2500506000, 59268685, 24 tz.transition 2049, 10, :o6, 2519254800, 59273893, 24 tz.transition 2050, 3, :o5, 2531955600, 59277421, 24 tz.transition 2050, 10, :o6, 2550704400, 59282629, 24 tz.transition 2051, 3, :o5, 2563405200, 59286157, 24 tz.transition 2051, 10, :o6, 2582154000, 59291365, 24 tz.transition 2052, 3, :o5, 2595459600, 59295061, 24 tz.transition 2052, 10, :o6, 2613603600, 59300101, 24 tz.transition 2053, 3, :o5, 2626909200, 59303797, 24 tz.transition 2053, 10, :o6, 2645053200, 59308837, 24 tz.transition 2054, 3, :o5, 2658358800, 59312533, 24 tz.transition 2054, 10, :o6, 2676502800, 59317573, 24 tz.transition 2055, 3, :o5, 2689808400, 59321269, 24 tz.transition 2055, 10, :o6, 2708557200, 59326477, 24 tz.transition 2056, 3, :o5, 2721258000, 59330005, 24 tz.transition 2056, 10, :o6, 2740006800, 59335213, 24 tz.transition 2057, 3, :o5, 2752707600, 59338741, 24 tz.transition 2057, 10, :o6, 2771456400, 59343949, 24 tz.transition 2058, 3, :o5, 2784762000, 59347645, 24 tz.transition 2058, 10, :o6, 2802906000, 59352685, 24 tz.transition 2059, 3, :o5, 2816211600, 59356381, 24 tz.transition 2059, 10, :o6, 2834355600, 59361421, 24 tz.transition 2060, 3, :o5, 2847661200, 59365117, 24 tz.transition 2060, 10, :o6, 2866410000, 59370325, 24 tz.transition 2061, 3, :o5, 2879110800, 59373853, 24 tz.transition 2061, 10, :o6, 2897859600, 59379061, 24 tz.transition 2062, 3, :o5, 2910560400, 59382589, 24 tz.transition 2062, 10, :o6, 2929309200, 59387797, 24 tz.transition 2063, 3, :o5, 2942010000, 59391325, 24 tz.transition 2063, 10, :o6, 2960758800, 59396533, 24 tz.transition 2064, 3, :o5, 2974064400, 59400229, 24 tz.transition 2064, 10, :o6, 2992208400, 59405269, 24 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Europe/Andorra.rb0000644000004100000410000002263412400401360026160 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Europe module Andorra include TimezoneDefinition timezone 'Europe/Andorra' do |tz| tz.offset :o0, 364, 0, :LMT tz.offset :o1, 0, 0, :WET tz.offset :o2, 3600, 0, :CET tz.offset :o3, 3600, 3600, :CEST tz.transition 1900, 12, :o1, -2177453164, 52172326709, 21600 tz.transition 1946, 9, :o2, -733881600, 4864187, 2 tz.transition 1985, 3, :o3, 481078800 tz.transition 1985, 9, :o2, 496803600 tz.transition 1986, 3, :o3, 512528400 tz.transition 1986, 9, :o2, 528253200 tz.transition 1987, 3, :o3, 543978000 tz.transition 1987, 9, :o2, 559702800 tz.transition 1988, 3, :o3, 575427600 tz.transition 1988, 9, :o2, 591152400 tz.transition 1989, 3, :o3, 606877200 tz.transition 1989, 9, :o2, 622602000 tz.transition 1990, 3, :o3, 638326800 tz.transition 1990, 9, :o2, 654656400 tz.transition 1991, 3, :o3, 670381200 tz.transition 1991, 9, :o2, 686106000 tz.transition 1992, 3, :o3, 701830800 tz.transition 1992, 9, :o2, 717555600 tz.transition 1993, 3, :o3, 733280400 tz.transition 1993, 9, :o2, 749005200 tz.transition 1994, 3, :o3, 764730000 tz.transition 1994, 9, :o2, 780454800 tz.transition 1995, 3, :o3, 796179600 tz.transition 1995, 9, :o2, 811904400 tz.transition 1996, 3, :o3, 828234000 tz.transition 1996, 10, :o2, 846378000 tz.transition 1997, 3, :o3, 859683600 tz.transition 1997, 10, :o2, 877827600 tz.transition 1998, 3, :o3, 891133200 tz.transition 1998, 10, :o2, 909277200 tz.transition 1999, 3, :o3, 922582800 tz.transition 1999, 10, :o2, 941331600 tz.transition 2000, 3, :o3, 954032400 tz.transition 2000, 10, :o2, 972781200 tz.transition 2001, 3, :o3, 985482000 tz.transition 2001, 10, :o2, 1004230800 tz.transition 2002, 3, :o3, 1017536400 tz.transition 2002, 10, :o2, 1035680400 tz.transition 2003, 3, :o3, 1048986000 tz.transition 2003, 10, :o2, 1067130000 tz.transition 2004, 3, :o3, 1080435600 tz.transition 2004, 10, :o2, 1099184400 tz.transition 2005, 3, :o3, 1111885200 tz.transition 2005, 10, :o2, 1130634000 tz.transition 2006, 3, :o3, 1143334800 tz.transition 2006, 10, :o2, 1162083600 tz.transition 2007, 3, :o3, 1174784400 tz.transition 2007, 10, :o2, 1193533200 tz.transition 2008, 3, :o3, 1206838800 tz.transition 2008, 10, :o2, 1224982800 tz.transition 2009, 3, :o3, 1238288400 tz.transition 2009, 10, :o2, 1256432400 tz.transition 2010, 3, :o3, 1269738000 tz.transition 2010, 10, :o2, 1288486800 tz.transition 2011, 3, :o3, 1301187600 tz.transition 2011, 10, :o2, 1319936400 tz.transition 2012, 3, :o3, 1332637200 tz.transition 2012, 10, :o2, 1351386000 tz.transition 2013, 3, :o3, 1364691600 tz.transition 2013, 10, :o2, 1382835600 tz.transition 2014, 3, :o3, 1396141200 tz.transition 2014, 10, :o2, 1414285200 tz.transition 2015, 3, :o3, 1427590800 tz.transition 2015, 10, :o2, 1445734800 tz.transition 2016, 3, :o3, 1459040400 tz.transition 2016, 10, :o2, 1477789200 tz.transition 2017, 3, :o3, 1490490000 tz.transition 2017, 10, :o2, 1509238800 tz.transition 2018, 3, :o3, 1521939600 tz.transition 2018, 10, :o2, 1540688400 tz.transition 2019, 3, :o3, 1553994000 tz.transition 2019, 10, :o2, 1572138000 tz.transition 2020, 3, :o3, 1585443600 tz.transition 2020, 10, :o2, 1603587600 tz.transition 2021, 3, :o3, 1616893200 tz.transition 2021, 10, :o2, 1635642000 tz.transition 2022, 3, :o3, 1648342800 tz.transition 2022, 10, :o2, 1667091600 tz.transition 2023, 3, :o3, 1679792400 tz.transition 2023, 10, :o2, 1698541200 tz.transition 2024, 3, :o3, 1711846800 tz.transition 2024, 10, :o2, 1729990800 tz.transition 2025, 3, :o3, 1743296400 tz.transition 2025, 10, :o2, 1761440400 tz.transition 2026, 3, :o3, 1774746000 tz.transition 2026, 10, :o2, 1792890000 tz.transition 2027, 3, :o3, 1806195600 tz.transition 2027, 10, :o2, 1824944400 tz.transition 2028, 3, :o3, 1837645200 tz.transition 2028, 10, :o2, 1856394000 tz.transition 2029, 3, :o3, 1869094800 tz.transition 2029, 10, :o2, 1887843600 tz.transition 2030, 3, :o3, 1901149200 tz.transition 2030, 10, :o2, 1919293200 tz.transition 2031, 3, :o3, 1932598800 tz.transition 2031, 10, :o2, 1950742800 tz.transition 2032, 3, :o3, 1964048400 tz.transition 2032, 10, :o2, 1982797200 tz.transition 2033, 3, :o3, 1995498000 tz.transition 2033, 10, :o2, 2014246800 tz.transition 2034, 3, :o3, 2026947600 tz.transition 2034, 10, :o2, 2045696400 tz.transition 2035, 3, :o3, 2058397200 tz.transition 2035, 10, :o2, 2077146000 tz.transition 2036, 3, :o3, 2090451600 tz.transition 2036, 10, :o2, 2108595600 tz.transition 2037, 3, :o3, 2121901200 tz.transition 2037, 10, :o2, 2140045200 tz.transition 2038, 3, :o3, 2153350800, 59172253, 24 tz.transition 2038, 10, :o2, 2172099600, 59177461, 24 tz.transition 2039, 3, :o3, 2184800400, 59180989, 24 tz.transition 2039, 10, :o2, 2203549200, 59186197, 24 tz.transition 2040, 3, :o3, 2216250000, 59189725, 24 tz.transition 2040, 10, :o2, 2234998800, 59194933, 24 tz.transition 2041, 3, :o3, 2248304400, 59198629, 24 tz.transition 2041, 10, :o2, 2266448400, 59203669, 24 tz.transition 2042, 3, :o3, 2279754000, 59207365, 24 tz.transition 2042, 10, :o2, 2297898000, 59212405, 24 tz.transition 2043, 3, :o3, 2311203600, 59216101, 24 tz.transition 2043, 10, :o2, 2329347600, 59221141, 24 tz.transition 2044, 3, :o3, 2342653200, 59224837, 24 tz.transition 2044, 10, :o2, 2361402000, 59230045, 24 tz.transition 2045, 3, :o3, 2374102800, 59233573, 24 tz.transition 2045, 10, :o2, 2392851600, 59238781, 24 tz.transition 2046, 3, :o3, 2405552400, 59242309, 24 tz.transition 2046, 10, :o2, 2424301200, 59247517, 24 tz.transition 2047, 3, :o3, 2437606800, 59251213, 24 tz.transition 2047, 10, :o2, 2455750800, 59256253, 24 tz.transition 2048, 3, :o3, 2469056400, 59259949, 24 tz.transition 2048, 10, :o2, 2487200400, 59264989, 24 tz.transition 2049, 3, :o3, 2500506000, 59268685, 24 tz.transition 2049, 10, :o2, 2519254800, 59273893, 24 tz.transition 2050, 3, :o3, 2531955600, 59277421, 24 tz.transition 2050, 10, :o2, 2550704400, 59282629, 24 tz.transition 2051, 3, :o3, 2563405200, 59286157, 24 tz.transition 2051, 10, :o2, 2582154000, 59291365, 24 tz.transition 2052, 3, :o3, 2595459600, 59295061, 24 tz.transition 2052, 10, :o2, 2613603600, 59300101, 24 tz.transition 2053, 3, :o3, 2626909200, 59303797, 24 tz.transition 2053, 10, :o2, 2645053200, 59308837, 24 tz.transition 2054, 3, :o3, 2658358800, 59312533, 24 tz.transition 2054, 10, :o2, 2676502800, 59317573, 24 tz.transition 2055, 3, :o3, 2689808400, 59321269, 24 tz.transition 2055, 10, :o2, 2708557200, 59326477, 24 tz.transition 2056, 3, :o3, 2721258000, 59330005, 24 tz.transition 2056, 10, :o2, 2740006800, 59335213, 24 tz.transition 2057, 3, :o3, 2752707600, 59338741, 24 tz.transition 2057, 10, :o2, 2771456400, 59343949, 24 tz.transition 2058, 3, :o3, 2784762000, 59347645, 24 tz.transition 2058, 10, :o2, 2802906000, 59352685, 24 tz.transition 2059, 3, :o3, 2816211600, 59356381, 24 tz.transition 2059, 10, :o2, 2834355600, 59361421, 24 tz.transition 2060, 3, :o3, 2847661200, 59365117, 24 tz.transition 2060, 10, :o2, 2866410000, 59370325, 24 tz.transition 2061, 3, :o3, 2879110800, 59373853, 24 tz.transition 2061, 10, :o2, 2897859600, 59379061, 24 tz.transition 2062, 3, :o3, 2910560400, 59382589, 24 tz.transition 2062, 10, :o2, 2929309200, 59387797, 24 tz.transition 2063, 3, :o3, 2942010000, 59391325, 24 tz.transition 2063, 10, :o2, 2960758800, 59396533, 24 tz.transition 2064, 3, :o3, 2974064400, 59400229, 24 tz.transition 2064, 10, :o2, 2992208400, 59405269, 24 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Europe/Paris.rb0000644000004100000410000003424312400401360025647 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Europe module Paris include TimezoneDefinition timezone 'Europe/Paris' do |tz| tz.offset :o0, 561, 0, :LMT tz.offset :o1, 561, 0, :PMT tz.offset :o2, 0, 0, :WET tz.offset :o3, 0, 3600, :WEST tz.offset :o4, 3600, 3600, :CEST tz.offset :o5, 3600, 0, :CET tz.offset :o6, 0, 7200, :WEMT tz.transition 1891, 3, :o1, -2486678901, 69460027033, 28800 tz.transition 1911, 3, :o2, -1855958901, 69670267033, 28800 tz.transition 1916, 6, :o3, -1689814800, 58104707, 24 tz.transition 1916, 10, :o2, -1680397200, 58107323, 24 tz.transition 1917, 3, :o3, -1665363600, 58111499, 24 tz.transition 1917, 10, :o2, -1648342800, 58116227, 24 tz.transition 1918, 3, :o3, -1635123600, 58119899, 24 tz.transition 1918, 10, :o2, -1616893200, 58124963, 24 tz.transition 1919, 3, :o3, -1604278800, 58128467, 24 tz.transition 1919, 10, :o2, -1585443600, 58133699, 24 tz.transition 1920, 2, :o3, -1574038800, 58136867, 24 tz.transition 1920, 10, :o2, -1552266000, 58142915, 24 tz.transition 1921, 3, :o3, -1539997200, 58146323, 24 tz.transition 1921, 10, :o2, -1520557200, 58151723, 24 tz.transition 1922, 3, :o3, -1507510800, 58155347, 24 tz.transition 1922, 10, :o2, -1490576400, 58160051, 24 tz.transition 1923, 5, :o3, -1470618000, 58165595, 24 tz.transition 1923, 10, :o2, -1459126800, 58168787, 24 tz.transition 1924, 3, :o3, -1444006800, 58172987, 24 tz.transition 1924, 10, :o2, -1427677200, 58177523, 24 tz.transition 1925, 4, :o3, -1411952400, 58181891, 24 tz.transition 1925, 10, :o2, -1396227600, 58186259, 24 tz.transition 1926, 4, :o3, -1379293200, 58190963, 24 tz.transition 1926, 10, :o2, -1364778000, 58194995, 24 tz.transition 1927, 4, :o3, -1348448400, 58199531, 24 tz.transition 1927, 10, :o2, -1333328400, 58203731, 24 tz.transition 1928, 4, :o3, -1316394000, 58208435, 24 tz.transition 1928, 10, :o2, -1301274000, 58212635, 24 tz.transition 1929, 4, :o3, -1284339600, 58217339, 24 tz.transition 1929, 10, :o2, -1269824400, 58221371, 24 tz.transition 1930, 4, :o3, -1253494800, 58225907, 24 tz.transition 1930, 10, :o2, -1238374800, 58230107, 24 tz.transition 1931, 4, :o3, -1221440400, 58234811, 24 tz.transition 1931, 10, :o2, -1206925200, 58238843, 24 tz.transition 1932, 4, :o3, -1191200400, 58243211, 24 tz.transition 1932, 10, :o2, -1175475600, 58247579, 24 tz.transition 1933, 3, :o3, -1160355600, 58251779, 24 tz.transition 1933, 10, :o2, -1143421200, 58256483, 24 tz.transition 1934, 4, :o3, -1127696400, 58260851, 24 tz.transition 1934, 10, :o2, -1111971600, 58265219, 24 tz.transition 1935, 3, :o3, -1096851600, 58269419, 24 tz.transition 1935, 10, :o2, -1080522000, 58273955, 24 tz.transition 1936, 4, :o3, -1063587600, 58278659, 24 tz.transition 1936, 10, :o2, -1049072400, 58282691, 24 tz.transition 1937, 4, :o3, -1033347600, 58287059, 24 tz.transition 1937, 10, :o2, -1017622800, 58291427, 24 tz.transition 1938, 3, :o3, -1002502800, 58295627, 24 tz.transition 1938, 10, :o2, -986173200, 58300163, 24 tz.transition 1939, 4, :o3, -969238800, 58304867, 24 tz.transition 1939, 11, :o2, -950490000, 58310075, 24 tz.transition 1940, 2, :o3, -942012000, 29156215, 12 tz.transition 1940, 6, :o4, -932436000, 29157545, 12 tz.transition 1942, 11, :o5, -857257200, 58335973, 24 tz.transition 1943, 3, :o4, -844556400, 58339501, 24 tz.transition 1943, 10, :o5, -828226800, 58344037, 24 tz.transition 1944, 4, :o4, -812502000, 58348405, 24 tz.transition 1944, 8, :o6, -800071200, 29175929, 12 tz.transition 1944, 10, :o3, -796266000, 58352915, 24 tz.transition 1945, 4, :o6, -781052400, 58357141, 24 tz.transition 1945, 9, :o5, -766623600, 58361149, 24 tz.transition 1976, 3, :o4, 196819200 tz.transition 1976, 9, :o5, 212540400 tz.transition 1977, 4, :o4, 228877200 tz.transition 1977, 9, :o5, 243997200 tz.transition 1978, 4, :o4, 260326800 tz.transition 1978, 10, :o5, 276051600 tz.transition 1979, 4, :o4, 291776400 tz.transition 1979, 9, :o5, 307501200 tz.transition 1980, 4, :o4, 323830800 tz.transition 1980, 9, :o5, 338950800 tz.transition 1981, 3, :o4, 354675600 tz.transition 1981, 9, :o5, 370400400 tz.transition 1982, 3, :o4, 386125200 tz.transition 1982, 9, :o5, 401850000 tz.transition 1983, 3, :o4, 417574800 tz.transition 1983, 9, :o5, 433299600 tz.transition 1984, 3, :o4, 449024400 tz.transition 1984, 9, :o5, 465354000 tz.transition 1985, 3, :o4, 481078800 tz.transition 1985, 9, :o5, 496803600 tz.transition 1986, 3, :o4, 512528400 tz.transition 1986, 9, :o5, 528253200 tz.transition 1987, 3, :o4, 543978000 tz.transition 1987, 9, :o5, 559702800 tz.transition 1988, 3, :o4, 575427600 tz.transition 1988, 9, :o5, 591152400 tz.transition 1989, 3, :o4, 606877200 tz.transition 1989, 9, :o5, 622602000 tz.transition 1990, 3, :o4, 638326800 tz.transition 1990, 9, :o5, 654656400 tz.transition 1991, 3, :o4, 670381200 tz.transition 1991, 9, :o5, 686106000 tz.transition 1992, 3, :o4, 701830800 tz.transition 1992, 9, :o5, 717555600 tz.transition 1993, 3, :o4, 733280400 tz.transition 1993, 9, :o5, 749005200 tz.transition 1994, 3, :o4, 764730000 tz.transition 1994, 9, :o5, 780454800 tz.transition 1995, 3, :o4, 796179600 tz.transition 1995, 9, :o5, 811904400 tz.transition 1996, 3, :o4, 828234000 tz.transition 1996, 10, :o5, 846378000 tz.transition 1997, 3, :o4, 859683600 tz.transition 1997, 10, :o5, 877827600 tz.transition 1998, 3, :o4, 891133200 tz.transition 1998, 10, :o5, 909277200 tz.transition 1999, 3, :o4, 922582800 tz.transition 1999, 10, :o5, 941331600 tz.transition 2000, 3, :o4, 954032400 tz.transition 2000, 10, :o5, 972781200 tz.transition 2001, 3, :o4, 985482000 tz.transition 2001, 10, :o5, 1004230800 tz.transition 2002, 3, :o4, 1017536400 tz.transition 2002, 10, :o5, 1035680400 tz.transition 2003, 3, :o4, 1048986000 tz.transition 2003, 10, :o5, 1067130000 tz.transition 2004, 3, :o4, 1080435600 tz.transition 2004, 10, :o5, 1099184400 tz.transition 2005, 3, :o4, 1111885200 tz.transition 2005, 10, :o5, 1130634000 tz.transition 2006, 3, :o4, 1143334800 tz.transition 2006, 10, :o5, 1162083600 tz.transition 2007, 3, :o4, 1174784400 tz.transition 2007, 10, :o5, 1193533200 tz.transition 2008, 3, :o4, 1206838800 tz.transition 2008, 10, :o5, 1224982800 tz.transition 2009, 3, :o4, 1238288400 tz.transition 2009, 10, :o5, 1256432400 tz.transition 2010, 3, :o4, 1269738000 tz.transition 2010, 10, :o5, 1288486800 tz.transition 2011, 3, :o4, 1301187600 tz.transition 2011, 10, :o5, 1319936400 tz.transition 2012, 3, :o4, 1332637200 tz.transition 2012, 10, :o5, 1351386000 tz.transition 2013, 3, :o4, 1364691600 tz.transition 2013, 10, :o5, 1382835600 tz.transition 2014, 3, :o4, 1396141200 tz.transition 2014, 10, :o5, 1414285200 tz.transition 2015, 3, :o4, 1427590800 tz.transition 2015, 10, :o5, 1445734800 tz.transition 2016, 3, :o4, 1459040400 tz.transition 2016, 10, :o5, 1477789200 tz.transition 2017, 3, :o4, 1490490000 tz.transition 2017, 10, :o5, 1509238800 tz.transition 2018, 3, :o4, 1521939600 tz.transition 2018, 10, :o5, 1540688400 tz.transition 2019, 3, :o4, 1553994000 tz.transition 2019, 10, :o5, 1572138000 tz.transition 2020, 3, :o4, 1585443600 tz.transition 2020, 10, :o5, 1603587600 tz.transition 2021, 3, :o4, 1616893200 tz.transition 2021, 10, :o5, 1635642000 tz.transition 2022, 3, :o4, 1648342800 tz.transition 2022, 10, :o5, 1667091600 tz.transition 2023, 3, :o4, 1679792400 tz.transition 2023, 10, :o5, 1698541200 tz.transition 2024, 3, :o4, 1711846800 tz.transition 2024, 10, :o5, 1729990800 tz.transition 2025, 3, :o4, 1743296400 tz.transition 2025, 10, :o5, 1761440400 tz.transition 2026, 3, :o4, 1774746000 tz.transition 2026, 10, :o5, 1792890000 tz.transition 2027, 3, :o4, 1806195600 tz.transition 2027, 10, :o5, 1824944400 tz.transition 2028, 3, :o4, 1837645200 tz.transition 2028, 10, :o5, 1856394000 tz.transition 2029, 3, :o4, 1869094800 tz.transition 2029, 10, :o5, 1887843600 tz.transition 2030, 3, :o4, 1901149200 tz.transition 2030, 10, :o5, 1919293200 tz.transition 2031, 3, :o4, 1932598800 tz.transition 2031, 10, :o5, 1950742800 tz.transition 2032, 3, :o4, 1964048400 tz.transition 2032, 10, :o5, 1982797200 tz.transition 2033, 3, :o4, 1995498000 tz.transition 2033, 10, :o5, 2014246800 tz.transition 2034, 3, :o4, 2026947600 tz.transition 2034, 10, :o5, 2045696400 tz.transition 2035, 3, :o4, 2058397200 tz.transition 2035, 10, :o5, 2077146000 tz.transition 2036, 3, :o4, 2090451600 tz.transition 2036, 10, :o5, 2108595600 tz.transition 2037, 3, :o4, 2121901200 tz.transition 2037, 10, :o5, 2140045200 tz.transition 2038, 3, :o4, 2153350800, 59172253, 24 tz.transition 2038, 10, :o5, 2172099600, 59177461, 24 tz.transition 2039, 3, :o4, 2184800400, 59180989, 24 tz.transition 2039, 10, :o5, 2203549200, 59186197, 24 tz.transition 2040, 3, :o4, 2216250000, 59189725, 24 tz.transition 2040, 10, :o5, 2234998800, 59194933, 24 tz.transition 2041, 3, :o4, 2248304400, 59198629, 24 tz.transition 2041, 10, :o5, 2266448400, 59203669, 24 tz.transition 2042, 3, :o4, 2279754000, 59207365, 24 tz.transition 2042, 10, :o5, 2297898000, 59212405, 24 tz.transition 2043, 3, :o4, 2311203600, 59216101, 24 tz.transition 2043, 10, :o5, 2329347600, 59221141, 24 tz.transition 2044, 3, :o4, 2342653200, 59224837, 24 tz.transition 2044, 10, :o5, 2361402000, 59230045, 24 tz.transition 2045, 3, :o4, 2374102800, 59233573, 24 tz.transition 2045, 10, :o5, 2392851600, 59238781, 24 tz.transition 2046, 3, :o4, 2405552400, 59242309, 24 tz.transition 2046, 10, :o5, 2424301200, 59247517, 24 tz.transition 2047, 3, :o4, 2437606800, 59251213, 24 tz.transition 2047, 10, :o5, 2455750800, 59256253, 24 tz.transition 2048, 3, :o4, 2469056400, 59259949, 24 tz.transition 2048, 10, :o5, 2487200400, 59264989, 24 tz.transition 2049, 3, :o4, 2500506000, 59268685, 24 tz.transition 2049, 10, :o5, 2519254800, 59273893, 24 tz.transition 2050, 3, :o4, 2531955600, 59277421, 24 tz.transition 2050, 10, :o5, 2550704400, 59282629, 24 tz.transition 2051, 3, :o4, 2563405200, 59286157, 24 tz.transition 2051, 10, :o5, 2582154000, 59291365, 24 tz.transition 2052, 3, :o4, 2595459600, 59295061, 24 tz.transition 2052, 10, :o5, 2613603600, 59300101, 24 tz.transition 2053, 3, :o4, 2626909200, 59303797, 24 tz.transition 2053, 10, :o5, 2645053200, 59308837, 24 tz.transition 2054, 3, :o4, 2658358800, 59312533, 24 tz.transition 2054, 10, :o5, 2676502800, 59317573, 24 tz.transition 2055, 3, :o4, 2689808400, 59321269, 24 tz.transition 2055, 10, :o5, 2708557200, 59326477, 24 tz.transition 2056, 3, :o4, 2721258000, 59330005, 24 tz.transition 2056, 10, :o5, 2740006800, 59335213, 24 tz.transition 2057, 3, :o4, 2752707600, 59338741, 24 tz.transition 2057, 10, :o5, 2771456400, 59343949, 24 tz.transition 2058, 3, :o4, 2784762000, 59347645, 24 tz.transition 2058, 10, :o5, 2802906000, 59352685, 24 tz.transition 2059, 3, :o4, 2816211600, 59356381, 24 tz.transition 2059, 10, :o5, 2834355600, 59361421, 24 tz.transition 2060, 3, :o4, 2847661200, 59365117, 24 tz.transition 2060, 10, :o5, 2866410000, 59370325, 24 tz.transition 2061, 3, :o4, 2879110800, 59373853, 24 tz.transition 2061, 10, :o5, 2897859600, 59379061, 24 tz.transition 2062, 3, :o4, 2910560400, 59382589, 24 tz.transition 2062, 10, :o5, 2929309200, 59387797, 24 tz.transition 2063, 3, :o4, 2942010000, 59391325, 24 tz.transition 2063, 10, :o5, 2960758800, 59396533, 24 tz.transition 2064, 3, :o4, 2974064400, 59400229, 24 tz.transition 2064, 10, :o5, 2992208400, 59405269, 24 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Europe/London.rb0000644000004100000410000004323312400401360026021 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Europe module London include TimezoneDefinition timezone 'Europe/London' do |tz| tz.offset :o0, -75, 0, :LMT tz.offset :o1, 0, 0, :GMT tz.offset :o2, 0, 3600, :BST tz.offset :o3, 0, 7200, :BDST tz.offset :o4, 3600, 0, :BST tz.transition 1847, 12, :o1, -3852662325, 2760187969, 1152 tz.transition 1916, 5, :o2, -1691964000, 29052055, 12 tz.transition 1916, 10, :o1, -1680472800, 29053651, 12 tz.transition 1917, 4, :o2, -1664143200, 29055919, 12 tz.transition 1917, 9, :o1, -1650146400, 29057863, 12 tz.transition 1918, 3, :o2, -1633903200, 29060119, 12 tz.transition 1918, 9, :o1, -1617487200, 29062399, 12 tz.transition 1919, 3, :o2, -1601848800, 29064571, 12 tz.transition 1919, 9, :o1, -1586037600, 29066767, 12 tz.transition 1920, 3, :o2, -1570399200, 29068939, 12 tz.transition 1920, 10, :o1, -1552168800, 29071471, 12 tz.transition 1921, 4, :o2, -1538344800, 29073391, 12 tz.transition 1921, 10, :o1, -1522533600, 29075587, 12 tz.transition 1922, 3, :o2, -1507500000, 29077675, 12 tz.transition 1922, 10, :o1, -1490565600, 29080027, 12 tz.transition 1923, 4, :o2, -1473631200, 29082379, 12 tz.transition 1923, 9, :o1, -1460930400, 29084143, 12 tz.transition 1924, 4, :o2, -1442786400, 29086663, 12 tz.transition 1924, 9, :o1, -1428876000, 29088595, 12 tz.transition 1925, 4, :o2, -1410732000, 29091115, 12 tz.transition 1925, 10, :o1, -1396216800, 29093131, 12 tz.transition 1926, 4, :o2, -1379282400, 29095483, 12 tz.transition 1926, 10, :o1, -1364767200, 29097499, 12 tz.transition 1927, 4, :o2, -1348437600, 29099767, 12 tz.transition 1927, 10, :o1, -1333317600, 29101867, 12 tz.transition 1928, 4, :o2, -1315778400, 29104303, 12 tz.transition 1928, 10, :o1, -1301263200, 29106319, 12 tz.transition 1929, 4, :o2, -1284328800, 29108671, 12 tz.transition 1929, 10, :o1, -1269813600, 29110687, 12 tz.transition 1930, 4, :o2, -1253484000, 29112955, 12 tz.transition 1930, 10, :o1, -1238364000, 29115055, 12 tz.transition 1931, 4, :o2, -1221429600, 29117407, 12 tz.transition 1931, 10, :o1, -1206914400, 29119423, 12 tz.transition 1932, 4, :o2, -1189980000, 29121775, 12 tz.transition 1932, 10, :o1, -1175464800, 29123791, 12 tz.transition 1933, 4, :o2, -1159135200, 29126059, 12 tz.transition 1933, 10, :o1, -1143410400, 29128243, 12 tz.transition 1934, 4, :o2, -1126476000, 29130595, 12 tz.transition 1934, 10, :o1, -1111960800, 29132611, 12 tz.transition 1935, 4, :o2, -1095631200, 29134879, 12 tz.transition 1935, 10, :o1, -1080511200, 29136979, 12 tz.transition 1936, 4, :o2, -1063576800, 29139331, 12 tz.transition 1936, 10, :o1, -1049061600, 29141347, 12 tz.transition 1937, 4, :o2, -1032127200, 29143699, 12 tz.transition 1937, 10, :o1, -1017612000, 29145715, 12 tz.transition 1938, 4, :o2, -1001282400, 29147983, 12 tz.transition 1938, 10, :o1, -986162400, 29150083, 12 tz.transition 1939, 4, :o2, -969228000, 29152435, 12 tz.transition 1939, 11, :o1, -950479200, 29155039, 12 tz.transition 1940, 2, :o2, -942012000, 29156215, 12 tz.transition 1941, 5, :o3, -904518000, 58322845, 24 tz.transition 1941, 8, :o2, -896050800, 58325197, 24 tz.transition 1942, 4, :o3, -875487600, 58330909, 24 tz.transition 1942, 8, :o2, -864601200, 58333933, 24 tz.transition 1943, 4, :o3, -844038000, 58339645, 24 tz.transition 1943, 8, :o2, -832546800, 58342837, 24 tz.transition 1944, 4, :o3, -812588400, 58348381, 24 tz.transition 1944, 9, :o2, -798073200, 58352413, 24 tz.transition 1945, 4, :o3, -781052400, 58357141, 24 tz.transition 1945, 7, :o2, -772066800, 58359637, 24 tz.transition 1945, 10, :o1, -764805600, 29180827, 12 tz.transition 1946, 4, :o2, -748476000, 29183095, 12 tz.transition 1946, 10, :o1, -733356000, 29185195, 12 tz.transition 1947, 3, :o2, -719445600, 29187127, 12 tz.transition 1947, 4, :o3, -717030000, 58374925, 24 tz.transition 1947, 8, :o2, -706748400, 58377781, 24 tz.transition 1947, 11, :o1, -699487200, 29189899, 12 tz.transition 1948, 3, :o2, -687996000, 29191495, 12 tz.transition 1948, 10, :o1, -668037600, 29194267, 12 tz.transition 1949, 4, :o2, -654732000, 29196115, 12 tz.transition 1949, 10, :o1, -636588000, 29198635, 12 tz.transition 1950, 4, :o2, -622072800, 29200651, 12 tz.transition 1950, 10, :o1, -605743200, 29202919, 12 tz.transition 1951, 4, :o2, -590623200, 29205019, 12 tz.transition 1951, 10, :o1, -574293600, 29207287, 12 tz.transition 1952, 4, :o2, -558568800, 29209471, 12 tz.transition 1952, 10, :o1, -542239200, 29211739, 12 tz.transition 1953, 4, :o2, -527119200, 29213839, 12 tz.transition 1953, 10, :o1, -512604000, 29215855, 12 tz.transition 1954, 4, :o2, -496274400, 29218123, 12 tz.transition 1954, 10, :o1, -481154400, 29220223, 12 tz.transition 1955, 4, :o2, -464220000, 29222575, 12 tz.transition 1955, 10, :o1, -449704800, 29224591, 12 tz.transition 1956, 4, :o2, -432165600, 29227027, 12 tz.transition 1956, 10, :o1, -417650400, 29229043, 12 tz.transition 1957, 4, :o2, -401320800, 29231311, 12 tz.transition 1957, 10, :o1, -386200800, 29233411, 12 tz.transition 1958, 4, :o2, -369266400, 29235763, 12 tz.transition 1958, 10, :o1, -354751200, 29237779, 12 tz.transition 1959, 4, :o2, -337816800, 29240131, 12 tz.transition 1959, 10, :o1, -323301600, 29242147, 12 tz.transition 1960, 4, :o2, -306972000, 29244415, 12 tz.transition 1960, 10, :o1, -291852000, 29246515, 12 tz.transition 1961, 3, :o2, -276732000, 29248615, 12 tz.transition 1961, 10, :o1, -257983200, 29251219, 12 tz.transition 1962, 3, :o2, -245282400, 29252983, 12 tz.transition 1962, 10, :o1, -226533600, 29255587, 12 tz.transition 1963, 3, :o2, -213228000, 29257435, 12 tz.transition 1963, 10, :o1, -195084000, 29259955, 12 tz.transition 1964, 3, :o2, -182383200, 29261719, 12 tz.transition 1964, 10, :o1, -163634400, 29264323, 12 tz.transition 1965, 3, :o2, -150933600, 29266087, 12 tz.transition 1965, 10, :o1, -132184800, 29268691, 12 tz.transition 1966, 3, :o2, -119484000, 29270455, 12 tz.transition 1966, 10, :o1, -100735200, 29273059, 12 tz.transition 1967, 3, :o2, -88034400, 29274823, 12 tz.transition 1967, 10, :o1, -68680800, 29277511, 12 tz.transition 1968, 2, :o2, -59004000, 29278855, 12 tz.transition 1968, 10, :o4, -37242000, 58563755, 24 tz.transition 1971, 10, :o1, 57722400 tz.transition 1972, 3, :o2, 69818400 tz.transition 1972, 10, :o1, 89172000 tz.transition 1973, 3, :o2, 101268000 tz.transition 1973, 10, :o1, 120621600 tz.transition 1974, 3, :o2, 132717600 tz.transition 1974, 10, :o1, 152071200 tz.transition 1975, 3, :o2, 164167200 tz.transition 1975, 10, :o1, 183520800 tz.transition 1976, 3, :o2, 196221600 tz.transition 1976, 10, :o1, 214970400 tz.transition 1977, 3, :o2, 227671200 tz.transition 1977, 10, :o1, 246420000 tz.transition 1978, 3, :o2, 259120800 tz.transition 1978, 10, :o1, 278474400 tz.transition 1979, 3, :o2, 290570400 tz.transition 1979, 10, :o1, 309924000 tz.transition 1980, 3, :o2, 322020000 tz.transition 1980, 10, :o1, 341373600 tz.transition 1981, 3, :o2, 354675600 tz.transition 1981, 10, :o1, 372819600 tz.transition 1982, 3, :o2, 386125200 tz.transition 1982, 10, :o1, 404269200 tz.transition 1983, 3, :o2, 417574800 tz.transition 1983, 10, :o1, 435718800 tz.transition 1984, 3, :o2, 449024400 tz.transition 1984, 10, :o1, 467773200 tz.transition 1985, 3, :o2, 481078800 tz.transition 1985, 10, :o1, 499222800 tz.transition 1986, 3, :o2, 512528400 tz.transition 1986, 10, :o1, 530672400 tz.transition 1987, 3, :o2, 543978000 tz.transition 1987, 10, :o1, 562122000 tz.transition 1988, 3, :o2, 575427600 tz.transition 1988, 10, :o1, 593571600 tz.transition 1989, 3, :o2, 606877200 tz.transition 1989, 10, :o1, 625626000 tz.transition 1990, 3, :o2, 638326800 tz.transition 1990, 10, :o1, 657075600 tz.transition 1991, 3, :o2, 670381200 tz.transition 1991, 10, :o1, 688525200 tz.transition 1992, 3, :o2, 701830800 tz.transition 1992, 10, :o1, 719974800 tz.transition 1993, 3, :o2, 733280400 tz.transition 1993, 10, :o1, 751424400 tz.transition 1994, 3, :o2, 764730000 tz.transition 1994, 10, :o1, 782874000 tz.transition 1995, 3, :o2, 796179600 tz.transition 1995, 10, :o1, 814323600 tz.transition 1996, 3, :o2, 828234000 tz.transition 1996, 10, :o1, 846378000 tz.transition 1997, 3, :o2, 859683600 tz.transition 1997, 10, :o1, 877827600 tz.transition 1998, 3, :o2, 891133200 tz.transition 1998, 10, :o1, 909277200 tz.transition 1999, 3, :o2, 922582800 tz.transition 1999, 10, :o1, 941331600 tz.transition 2000, 3, :o2, 954032400 tz.transition 2000, 10, :o1, 972781200 tz.transition 2001, 3, :o2, 985482000 tz.transition 2001, 10, :o1, 1004230800 tz.transition 2002, 3, :o2, 1017536400 tz.transition 2002, 10, :o1, 1035680400 tz.transition 2003, 3, :o2, 1048986000 tz.transition 2003, 10, :o1, 1067130000 tz.transition 2004, 3, :o2, 1080435600 tz.transition 2004, 10, :o1, 1099184400 tz.transition 2005, 3, :o2, 1111885200 tz.transition 2005, 10, :o1, 1130634000 tz.transition 2006, 3, :o2, 1143334800 tz.transition 2006, 10, :o1, 1162083600 tz.transition 2007, 3, :o2, 1174784400 tz.transition 2007, 10, :o1, 1193533200 tz.transition 2008, 3, :o2, 1206838800 tz.transition 2008, 10, :o1, 1224982800 tz.transition 2009, 3, :o2, 1238288400 tz.transition 2009, 10, :o1, 1256432400 tz.transition 2010, 3, :o2, 1269738000 tz.transition 2010, 10, :o1, 1288486800 tz.transition 2011, 3, :o2, 1301187600 tz.transition 2011, 10, :o1, 1319936400 tz.transition 2012, 3, :o2, 1332637200 tz.transition 2012, 10, :o1, 1351386000 tz.transition 2013, 3, :o2, 1364691600 tz.transition 2013, 10, :o1, 1382835600 tz.transition 2014, 3, :o2, 1396141200 tz.transition 2014, 10, :o1, 1414285200 tz.transition 2015, 3, :o2, 1427590800 tz.transition 2015, 10, :o1, 1445734800 tz.transition 2016, 3, :o2, 1459040400 tz.transition 2016, 10, :o1, 1477789200 tz.transition 2017, 3, :o2, 1490490000 tz.transition 2017, 10, :o1, 1509238800 tz.transition 2018, 3, :o2, 1521939600 tz.transition 2018, 10, :o1, 1540688400 tz.transition 2019, 3, :o2, 1553994000 tz.transition 2019, 10, :o1, 1572138000 tz.transition 2020, 3, :o2, 1585443600 tz.transition 2020, 10, :o1, 1603587600 tz.transition 2021, 3, :o2, 1616893200 tz.transition 2021, 10, :o1, 1635642000 tz.transition 2022, 3, :o2, 1648342800 tz.transition 2022, 10, :o1, 1667091600 tz.transition 2023, 3, :o2, 1679792400 tz.transition 2023, 10, :o1, 1698541200 tz.transition 2024, 3, :o2, 1711846800 tz.transition 2024, 10, :o1, 1729990800 tz.transition 2025, 3, :o2, 1743296400 tz.transition 2025, 10, :o1, 1761440400 tz.transition 2026, 3, :o2, 1774746000 tz.transition 2026, 10, :o1, 1792890000 tz.transition 2027, 3, :o2, 1806195600 tz.transition 2027, 10, :o1, 1824944400 tz.transition 2028, 3, :o2, 1837645200 tz.transition 2028, 10, :o1, 1856394000 tz.transition 2029, 3, :o2, 1869094800 tz.transition 2029, 10, :o1, 1887843600 tz.transition 2030, 3, :o2, 1901149200 tz.transition 2030, 10, :o1, 1919293200 tz.transition 2031, 3, :o2, 1932598800 tz.transition 2031, 10, :o1, 1950742800 tz.transition 2032, 3, :o2, 1964048400 tz.transition 2032, 10, :o1, 1982797200 tz.transition 2033, 3, :o2, 1995498000 tz.transition 2033, 10, :o1, 2014246800 tz.transition 2034, 3, :o2, 2026947600 tz.transition 2034, 10, :o1, 2045696400 tz.transition 2035, 3, :o2, 2058397200 tz.transition 2035, 10, :o1, 2077146000 tz.transition 2036, 3, :o2, 2090451600 tz.transition 2036, 10, :o1, 2108595600 tz.transition 2037, 3, :o2, 2121901200 tz.transition 2037, 10, :o1, 2140045200 tz.transition 2038, 3, :o2, 2153350800, 59172253, 24 tz.transition 2038, 10, :o1, 2172099600, 59177461, 24 tz.transition 2039, 3, :o2, 2184800400, 59180989, 24 tz.transition 2039, 10, :o1, 2203549200, 59186197, 24 tz.transition 2040, 3, :o2, 2216250000, 59189725, 24 tz.transition 2040, 10, :o1, 2234998800, 59194933, 24 tz.transition 2041, 3, :o2, 2248304400, 59198629, 24 tz.transition 2041, 10, :o1, 2266448400, 59203669, 24 tz.transition 2042, 3, :o2, 2279754000, 59207365, 24 tz.transition 2042, 10, :o1, 2297898000, 59212405, 24 tz.transition 2043, 3, :o2, 2311203600, 59216101, 24 tz.transition 2043, 10, :o1, 2329347600, 59221141, 24 tz.transition 2044, 3, :o2, 2342653200, 59224837, 24 tz.transition 2044, 10, :o1, 2361402000, 59230045, 24 tz.transition 2045, 3, :o2, 2374102800, 59233573, 24 tz.transition 2045, 10, :o1, 2392851600, 59238781, 24 tz.transition 2046, 3, :o2, 2405552400, 59242309, 24 tz.transition 2046, 10, :o1, 2424301200, 59247517, 24 tz.transition 2047, 3, :o2, 2437606800, 59251213, 24 tz.transition 2047, 10, :o1, 2455750800, 59256253, 24 tz.transition 2048, 3, :o2, 2469056400, 59259949, 24 tz.transition 2048, 10, :o1, 2487200400, 59264989, 24 tz.transition 2049, 3, :o2, 2500506000, 59268685, 24 tz.transition 2049, 10, :o1, 2519254800, 59273893, 24 tz.transition 2050, 3, :o2, 2531955600, 59277421, 24 tz.transition 2050, 10, :o1, 2550704400, 59282629, 24 tz.transition 2051, 3, :o2, 2563405200, 59286157, 24 tz.transition 2051, 10, :o1, 2582154000, 59291365, 24 tz.transition 2052, 3, :o2, 2595459600, 59295061, 24 tz.transition 2052, 10, :o1, 2613603600, 59300101, 24 tz.transition 2053, 3, :o2, 2626909200, 59303797, 24 tz.transition 2053, 10, :o1, 2645053200, 59308837, 24 tz.transition 2054, 3, :o2, 2658358800, 59312533, 24 tz.transition 2054, 10, :o1, 2676502800, 59317573, 24 tz.transition 2055, 3, :o2, 2689808400, 59321269, 24 tz.transition 2055, 10, :o1, 2708557200, 59326477, 24 tz.transition 2056, 3, :o2, 2721258000, 59330005, 24 tz.transition 2056, 10, :o1, 2740006800, 59335213, 24 tz.transition 2057, 3, :o2, 2752707600, 59338741, 24 tz.transition 2057, 10, :o1, 2771456400, 59343949, 24 tz.transition 2058, 3, :o2, 2784762000, 59347645, 24 tz.transition 2058, 10, :o1, 2802906000, 59352685, 24 tz.transition 2059, 3, :o2, 2816211600, 59356381, 24 tz.transition 2059, 10, :o1, 2834355600, 59361421, 24 tz.transition 2060, 3, :o2, 2847661200, 59365117, 24 tz.transition 2060, 10, :o1, 2866410000, 59370325, 24 tz.transition 2061, 3, :o2, 2879110800, 59373853, 24 tz.transition 2061, 10, :o1, 2897859600, 59379061, 24 tz.transition 2062, 3, :o2, 2910560400, 59382589, 24 tz.transition 2062, 10, :o1, 2929309200, 59387797, 24 tz.transition 2063, 3, :o2, 2942010000, 59391325, 24 tz.transition 2063, 10, :o1, 2960758800, 59396533, 24 tz.transition 2064, 3, :o2, 2974064400, 59400229, 24 tz.transition 2064, 10, :o1, 2992208400, 59405269, 24 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Australia/0000755000004100000410000000000012400401360024724 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Australia/Melbourne.rb0000644000004100000410000002605312400401360027207 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Australia module Melbourne include TimezoneDefinition timezone 'Australia/Melbourne' do |tz| tz.offset :o0, 34792, 0, :LMT tz.offset :o1, 36000, 0, :AEST tz.offset :o2, 36000, 3600, :AEDT tz.transition 1895, 1, :o1, -2364111592, 26062831051, 10800 tz.transition 1916, 12, :o2, -1672567140, 3486569881, 1440 tz.transition 1917, 3, :o1, -1665392400, 19370497, 8 tz.transition 1941, 12, :o2, -883641600, 14582161, 6 tz.transition 1942, 3, :o1, -876128400, 19443577, 8 tz.transition 1942, 9, :o2, -860400000, 14583775, 6 tz.transition 1943, 3, :o1, -844678800, 19446489, 8 tz.transition 1943, 10, :o2, -828345600, 14586001, 6 tz.transition 1944, 3, :o1, -813229200, 19449401, 8 tz.transition 1971, 10, :o2, 57686400 tz.transition 1972, 2, :o1, 67968000 tz.transition 1972, 10, :o2, 89136000 tz.transition 1973, 3, :o1, 100022400 tz.transition 1973, 10, :o2, 120585600 tz.transition 1974, 3, :o1, 131472000 tz.transition 1974, 10, :o2, 152035200 tz.transition 1975, 3, :o1, 162921600 tz.transition 1975, 10, :o2, 183484800 tz.transition 1976, 3, :o1, 194976000 tz.transition 1976, 10, :o2, 215539200 tz.transition 1977, 3, :o1, 226425600 tz.transition 1977, 10, :o2, 246988800 tz.transition 1978, 3, :o1, 257875200 tz.transition 1978, 10, :o2, 278438400 tz.transition 1979, 3, :o1, 289324800 tz.transition 1979, 10, :o2, 309888000 tz.transition 1980, 3, :o1, 320774400 tz.transition 1980, 10, :o2, 341337600 tz.transition 1981, 2, :o1, 352224000 tz.transition 1981, 10, :o2, 372787200 tz.transition 1982, 3, :o1, 384278400 tz.transition 1982, 10, :o2, 404841600 tz.transition 1983, 3, :o1, 415728000 tz.transition 1983, 10, :o2, 436291200 tz.transition 1984, 3, :o1, 447177600 tz.transition 1984, 10, :o2, 467740800 tz.transition 1985, 3, :o1, 478627200 tz.transition 1985, 10, :o2, 499190400 tz.transition 1986, 3, :o1, 511286400 tz.transition 1986, 10, :o2, 530035200 tz.transition 1987, 3, :o1, 542736000 tz.transition 1987, 10, :o2, 561484800 tz.transition 1988, 3, :o1, 574790400 tz.transition 1988, 10, :o2, 594144000 tz.transition 1989, 3, :o1, 606240000 tz.transition 1989, 10, :o2, 625593600 tz.transition 1990, 3, :o1, 637689600 tz.transition 1990, 10, :o2, 657043200 tz.transition 1991, 3, :o1, 667929600 tz.transition 1991, 10, :o2, 688492800 tz.transition 1992, 2, :o1, 699379200 tz.transition 1992, 10, :o2, 719942400 tz.transition 1993, 3, :o1, 731433600 tz.transition 1993, 10, :o2, 751996800 tz.transition 1994, 3, :o1, 762883200 tz.transition 1994, 10, :o2, 783446400 tz.transition 1995, 3, :o1, 796147200 tz.transition 1995, 10, :o2, 814896000 tz.transition 1996, 3, :o1, 828201600 tz.transition 1996, 10, :o2, 846345600 tz.transition 1997, 3, :o1, 859651200 tz.transition 1997, 10, :o2, 877795200 tz.transition 1998, 3, :o1, 891100800 tz.transition 1998, 10, :o2, 909244800 tz.transition 1999, 3, :o1, 922550400 tz.transition 1999, 10, :o2, 941299200 tz.transition 2000, 3, :o1, 954000000 tz.transition 2000, 8, :o2, 967305600 tz.transition 2001, 3, :o1, 985449600 tz.transition 2001, 10, :o2, 1004198400 tz.transition 2002, 3, :o1, 1017504000 tz.transition 2002, 10, :o2, 1035648000 tz.transition 2003, 3, :o1, 1048953600 tz.transition 2003, 10, :o2, 1067097600 tz.transition 2004, 3, :o1, 1080403200 tz.transition 2004, 10, :o2, 1099152000 tz.transition 2005, 3, :o1, 1111852800 tz.transition 2005, 10, :o2, 1130601600 tz.transition 2006, 4, :o1, 1143907200 tz.transition 2006, 10, :o2, 1162051200 tz.transition 2007, 3, :o1, 1174752000 tz.transition 2007, 10, :o2, 1193500800 tz.transition 2008, 4, :o1, 1207411200 tz.transition 2008, 10, :o2, 1223136000 tz.transition 2009, 4, :o1, 1238860800 tz.transition 2009, 10, :o2, 1254585600 tz.transition 2010, 4, :o1, 1270310400 tz.transition 2010, 10, :o2, 1286035200 tz.transition 2011, 4, :o1, 1301760000 tz.transition 2011, 10, :o2, 1317484800 tz.transition 2012, 3, :o1, 1333209600 tz.transition 2012, 10, :o2, 1349539200 tz.transition 2013, 4, :o1, 1365264000 tz.transition 2013, 10, :o2, 1380988800 tz.transition 2014, 4, :o1, 1396713600 tz.transition 2014, 10, :o2, 1412438400 tz.transition 2015, 4, :o1, 1428163200 tz.transition 2015, 10, :o2, 1443888000 tz.transition 2016, 4, :o1, 1459612800 tz.transition 2016, 10, :o2, 1475337600 tz.transition 2017, 4, :o1, 1491062400 tz.transition 2017, 9, :o2, 1506787200 tz.transition 2018, 3, :o1, 1522512000 tz.transition 2018, 10, :o2, 1538841600 tz.transition 2019, 4, :o1, 1554566400 tz.transition 2019, 10, :o2, 1570291200 tz.transition 2020, 4, :o1, 1586016000 tz.transition 2020, 10, :o2, 1601740800 tz.transition 2021, 4, :o1, 1617465600 tz.transition 2021, 10, :o2, 1633190400 tz.transition 2022, 4, :o1, 1648915200 tz.transition 2022, 10, :o2, 1664640000 tz.transition 2023, 4, :o1, 1680364800 tz.transition 2023, 9, :o2, 1696089600 tz.transition 2024, 4, :o1, 1712419200 tz.transition 2024, 10, :o2, 1728144000 tz.transition 2025, 4, :o1, 1743868800 tz.transition 2025, 10, :o2, 1759593600 tz.transition 2026, 4, :o1, 1775318400 tz.transition 2026, 10, :o2, 1791043200 tz.transition 2027, 4, :o1, 1806768000 tz.transition 2027, 10, :o2, 1822492800 tz.transition 2028, 4, :o1, 1838217600 tz.transition 2028, 9, :o2, 1853942400 tz.transition 2029, 3, :o1, 1869667200 tz.transition 2029, 10, :o2, 1885996800 tz.transition 2030, 4, :o1, 1901721600 tz.transition 2030, 10, :o2, 1917446400 tz.transition 2031, 4, :o1, 1933171200 tz.transition 2031, 10, :o2, 1948896000 tz.transition 2032, 4, :o1, 1964620800 tz.transition 2032, 10, :o2, 1980345600 tz.transition 2033, 4, :o1, 1996070400 tz.transition 2033, 10, :o2, 2011795200 tz.transition 2034, 4, :o1, 2027520000 tz.transition 2034, 9, :o2, 2043244800 tz.transition 2035, 3, :o1, 2058969600 tz.transition 2035, 10, :o2, 2075299200 tz.transition 2036, 4, :o1, 2091024000 tz.transition 2036, 10, :o2, 2106748800 tz.transition 2037, 4, :o1, 2122473600 tz.transition 2037, 10, :o2, 2138198400 tz.transition 2038, 4, :o1, 2153923200, 14793103, 6 tz.transition 2038, 10, :o2, 2169648000, 14794195, 6 tz.transition 2039, 4, :o1, 2185372800, 14795287, 6 tz.transition 2039, 10, :o2, 2201097600, 14796379, 6 tz.transition 2040, 3, :o1, 2216822400, 14797471, 6 tz.transition 2040, 10, :o2, 2233152000, 14798605, 6 tz.transition 2041, 4, :o1, 2248876800, 14799697, 6 tz.transition 2041, 10, :o2, 2264601600, 14800789, 6 tz.transition 2042, 4, :o1, 2280326400, 14801881, 6 tz.transition 2042, 10, :o2, 2296051200, 14802973, 6 tz.transition 2043, 4, :o1, 2311776000, 14804065, 6 tz.transition 2043, 10, :o2, 2327500800, 14805157, 6 tz.transition 2044, 4, :o1, 2343225600, 14806249, 6 tz.transition 2044, 10, :o2, 2358950400, 14807341, 6 tz.transition 2045, 4, :o1, 2374675200, 14808433, 6 tz.transition 2045, 9, :o2, 2390400000, 14809525, 6 tz.transition 2046, 3, :o1, 2406124800, 14810617, 6 tz.transition 2046, 10, :o2, 2422454400, 14811751, 6 tz.transition 2047, 4, :o1, 2438179200, 14812843, 6 tz.transition 2047, 10, :o2, 2453904000, 14813935, 6 tz.transition 2048, 4, :o1, 2469628800, 14815027, 6 tz.transition 2048, 10, :o2, 2485353600, 14816119, 6 tz.transition 2049, 4, :o1, 2501078400, 14817211, 6 tz.transition 2049, 10, :o2, 2516803200, 14818303, 6 tz.transition 2050, 4, :o1, 2532528000, 14819395, 6 tz.transition 2050, 10, :o2, 2548252800, 14820487, 6 tz.transition 2051, 4, :o1, 2563977600, 14821579, 6 tz.transition 2051, 9, :o2, 2579702400, 14822671, 6 tz.transition 2052, 4, :o1, 2596032000, 14823805, 6 tz.transition 2052, 10, :o2, 2611756800, 14824897, 6 tz.transition 2053, 4, :o1, 2627481600, 14825989, 6 tz.transition 2053, 10, :o2, 2643206400, 14827081, 6 tz.transition 2054, 4, :o1, 2658931200, 14828173, 6 tz.transition 2054, 10, :o2, 2674656000, 14829265, 6 tz.transition 2055, 4, :o1, 2690380800, 14830357, 6 tz.transition 2055, 10, :o2, 2706105600, 14831449, 6 tz.transition 2056, 4, :o1, 2721830400, 14832541, 6 tz.transition 2056, 9, :o2, 2737555200, 14833633, 6 tz.transition 2057, 3, :o1, 2753280000, 14834725, 6 tz.transition 2057, 10, :o2, 2769609600, 14835859, 6 tz.transition 2058, 4, :o1, 2785334400, 14836951, 6 tz.transition 2058, 10, :o2, 2801059200, 14838043, 6 tz.transition 2059, 4, :o1, 2816784000, 14839135, 6 tz.transition 2059, 10, :o2, 2832508800, 14840227, 6 tz.transition 2060, 4, :o1, 2848233600, 14841319, 6 tz.transition 2060, 10, :o2, 2863958400, 14842411, 6 tz.transition 2061, 4, :o1, 2879683200, 14843503, 6 tz.transition 2061, 10, :o2, 2895408000, 14844595, 6 tz.transition 2062, 4, :o1, 2911132800, 14845687, 6 tz.transition 2062, 9, :o2, 2926857600, 14846779, 6 tz.transition 2063, 3, :o1, 2942582400, 14847871, 6 tz.transition 2063, 10, :o2, 2958912000, 14849005, 6 tz.transition 2064, 4, :o1, 2974636800, 14850097, 6 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/America/0000755000004100000410000000000012400401360024340 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/0000755000004100000410000000000012400401360026250 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/America/Argentina/Buenos_Aires.rb0000644000004100000410000001066712400401360031165 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module America module Argentina module Buenos_Aires include TimezoneDefinition timezone 'America/Argentina/Buenos_Aires' do |tz| tz.offset :o0, -14028, 0, :LMT tz.offset :o1, -15408, 0, :CMT tz.offset :o2, -14400, 0, :ART tz.offset :o3, -14400, 3600, :ARST tz.offset :o4, -10800, 0, :ART tz.offset :o5, -10800, 3600, :ARST tz.transition 1894, 10, :o1, -2372097972, 17374555169, 7200 tz.transition 1920, 5, :o2, -1567453392, 1453467407, 600 tz.transition 1930, 12, :o3, -1233432000, 7278935, 3 tz.transition 1931, 4, :o2, -1222981200, 19411461, 8 tz.transition 1931, 10, :o3, -1205956800, 7279889, 3 tz.transition 1932, 3, :o2, -1194037200, 19414141, 8 tz.transition 1932, 11, :o3, -1172865600, 7281038, 3 tz.transition 1933, 3, :o2, -1162501200, 19417061, 8 tz.transition 1933, 11, :o3, -1141329600, 7282133, 3 tz.transition 1934, 3, :o2, -1130965200, 19419981, 8 tz.transition 1934, 11, :o3, -1109793600, 7283228, 3 tz.transition 1935, 3, :o2, -1099429200, 19422901, 8 tz.transition 1935, 11, :o3, -1078257600, 7284323, 3 tz.transition 1936, 3, :o2, -1067806800, 19425829, 8 tz.transition 1936, 11, :o3, -1046635200, 7285421, 3 tz.transition 1937, 3, :o2, -1036270800, 19428749, 8 tz.transition 1937, 11, :o3, -1015099200, 7286516, 3 tz.transition 1938, 3, :o2, -1004734800, 19431669, 8 tz.transition 1938, 11, :o3, -983563200, 7287611, 3 tz.transition 1939, 3, :o2, -973198800, 19434589, 8 tz.transition 1939, 11, :o3, -952027200, 7288706, 3 tz.transition 1940, 3, :o2, -941576400, 19437517, 8 tz.transition 1940, 7, :o3, -931032000, 7289435, 3 tz.transition 1941, 6, :o2, -900882000, 19441285, 8 tz.transition 1941, 10, :o3, -890337600, 7290848, 3 tz.transition 1943, 8, :o2, -833749200, 19447501, 8 tz.transition 1943, 10, :o3, -827265600, 7293038, 3 tz.transition 1946, 3, :o2, -752274000, 19455045, 8 tz.transition 1946, 10, :o3, -733780800, 7296284, 3 tz.transition 1963, 10, :o2, -197326800, 19506429, 8 tz.transition 1963, 12, :o3, -190843200, 7315136, 3 tz.transition 1964, 3, :o2, -184194000, 19507645, 8 tz.transition 1964, 10, :o3, -164491200, 7316051, 3 tz.transition 1965, 3, :o2, -152658000, 19510565, 8 tz.transition 1965, 10, :o3, -132955200, 7317146, 3 tz.transition 1966, 3, :o2, -121122000, 19513485, 8 tz.transition 1966, 10, :o3, -101419200, 7318241, 3 tz.transition 1967, 4, :o2, -86821200, 19516661, 8 tz.transition 1967, 10, :o3, -71092800, 7319294, 3 tz.transition 1968, 4, :o2, -54766800, 19519629, 8 tz.transition 1968, 10, :o3, -39038400, 7320407, 3 tz.transition 1969, 4, :o2, -23317200, 19522541, 8 tz.transition 1969, 10, :o4, -7588800, 7321499, 3 tz.transition 1974, 1, :o5, 128142000 tz.transition 1974, 5, :o4, 136605600 tz.transition 1988, 12, :o5, 596948400 tz.transition 1989, 3, :o4, 605066400 tz.transition 1989, 10, :o5, 624423600 tz.transition 1990, 3, :o4, 636516000 tz.transition 1990, 10, :o5, 656478000 tz.transition 1991, 3, :o4, 667965600 tz.transition 1991, 10, :o5, 687927600 tz.transition 1992, 3, :o4, 699415200 tz.transition 1992, 10, :o5, 719377200 tz.transition 1993, 3, :o4, 731469600 tz.transition 1999, 10, :o3, 938919600 tz.transition 2000, 3, :o4, 952052400 tz.transition 2007, 12, :o5, 1198983600 tz.transition 2008, 3, :o4, 1205632800 tz.transition 2008, 10, :o5, 1224385200 tz.transition 2009, 3, :o4, 1237082400 end end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/America/New_York.rb0000644000004100000410000004210512400401360026424 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module America module New_York include TimezoneDefinition timezone 'America/New_York' do |tz| tz.offset :o0, -17762, 0, :LMT tz.offset :o1, -18000, 0, :EST tz.offset :o2, -18000, 3600, :EDT tz.offset :o3, -18000, 3600, :EWT tz.offset :o4, -18000, 3600, :EPT tz.transition 1883, 11, :o1, -2717650800, 57819197, 24 tz.transition 1918, 3, :o2, -1633280400, 58120411, 24 tz.transition 1918, 10, :o1, -1615140000, 9687575, 4 tz.transition 1919, 3, :o2, -1601830800, 58129147, 24 tz.transition 1919, 10, :o1, -1583690400, 9689031, 4 tz.transition 1920, 3, :o2, -1570381200, 58137883, 24 tz.transition 1920, 10, :o1, -1551636000, 9690515, 4 tz.transition 1921, 4, :o2, -1536512400, 58147291, 24 tz.transition 1921, 9, :o1, -1523210400, 9691831, 4 tz.transition 1922, 4, :o2, -1504458000, 58156195, 24 tz.transition 1922, 9, :o1, -1491760800, 9693287, 4 tz.transition 1923, 4, :o2, -1473008400, 58164931, 24 tz.transition 1923, 9, :o1, -1459706400, 9694771, 4 tz.transition 1924, 4, :o2, -1441558800, 58173667, 24 tz.transition 1924, 9, :o1, -1428256800, 9696227, 4 tz.transition 1925, 4, :o2, -1410109200, 58182403, 24 tz.transition 1925, 9, :o1, -1396807200, 9697683, 4 tz.transition 1926, 4, :o2, -1378659600, 58191139, 24 tz.transition 1926, 9, :o1, -1365357600, 9699139, 4 tz.transition 1927, 4, :o2, -1347210000, 58199875, 24 tz.transition 1927, 9, :o1, -1333908000, 9700595, 4 tz.transition 1928, 4, :o2, -1315155600, 58208779, 24 tz.transition 1928, 9, :o1, -1301853600, 9702079, 4 tz.transition 1929, 4, :o2, -1283706000, 58217515, 24 tz.transition 1929, 9, :o1, -1270404000, 9703535, 4 tz.transition 1930, 4, :o2, -1252256400, 58226251, 24 tz.transition 1930, 9, :o1, -1238954400, 9704991, 4 tz.transition 1931, 4, :o2, -1220806800, 58234987, 24 tz.transition 1931, 9, :o1, -1207504800, 9706447, 4 tz.transition 1932, 4, :o2, -1189357200, 58243723, 24 tz.transition 1932, 9, :o1, -1176055200, 9707903, 4 tz.transition 1933, 4, :o2, -1157302800, 58252627, 24 tz.transition 1933, 9, :o1, -1144605600, 9709359, 4 tz.transition 1934, 4, :o2, -1125853200, 58261363, 24 tz.transition 1934, 9, :o1, -1112551200, 9710843, 4 tz.transition 1935, 4, :o2, -1094403600, 58270099, 24 tz.transition 1935, 9, :o1, -1081101600, 9712299, 4 tz.transition 1936, 4, :o2, -1062954000, 58278835, 24 tz.transition 1936, 9, :o1, -1049652000, 9713755, 4 tz.transition 1937, 4, :o2, -1031504400, 58287571, 24 tz.transition 1937, 9, :o1, -1018202400, 9715211, 4 tz.transition 1938, 4, :o2, -1000054800, 58296307, 24 tz.transition 1938, 9, :o1, -986752800, 9716667, 4 tz.transition 1939, 4, :o2, -968000400, 58305211, 24 tz.transition 1939, 9, :o1, -955303200, 9718123, 4 tz.transition 1940, 4, :o2, -936550800, 58313947, 24 tz.transition 1940, 9, :o1, -923248800, 9719607, 4 tz.transition 1941, 4, :o2, -905101200, 58322683, 24 tz.transition 1941, 9, :o1, -891799200, 9721063, 4 tz.transition 1942, 2, :o3, -880218000, 58329595, 24 tz.transition 1945, 8, :o4, -769395600, 58360379, 24 tz.transition 1945, 9, :o1, -765396000, 9726915, 4 tz.transition 1946, 4, :o2, -747248400, 58366531, 24 tz.transition 1946, 9, :o1, -733946400, 9728371, 4 tz.transition 1947, 4, :o2, -715798800, 58375267, 24 tz.transition 1947, 9, :o1, -702496800, 9729827, 4 tz.transition 1948, 4, :o2, -684349200, 58384003, 24 tz.transition 1948, 9, :o1, -671047200, 9731283, 4 tz.transition 1949, 4, :o2, -652899600, 58392739, 24 tz.transition 1949, 9, :o1, -639597600, 9732739, 4 tz.transition 1950, 4, :o2, -620845200, 58401643, 24 tz.transition 1950, 9, :o1, -608148000, 9734195, 4 tz.transition 1951, 4, :o2, -589395600, 58410379, 24 tz.transition 1951, 9, :o1, -576093600, 9735679, 4 tz.transition 1952, 4, :o2, -557946000, 58419115, 24 tz.transition 1952, 9, :o1, -544644000, 9737135, 4 tz.transition 1953, 4, :o2, -526496400, 58427851, 24 tz.transition 1953, 9, :o1, -513194400, 9738591, 4 tz.transition 1954, 4, :o2, -495046800, 58436587, 24 tz.transition 1954, 9, :o1, -481744800, 9740047, 4 tz.transition 1955, 4, :o2, -463597200, 58445323, 24 tz.transition 1955, 10, :o1, -447271200, 9741643, 4 tz.transition 1956, 4, :o2, -431542800, 58454227, 24 tz.transition 1956, 10, :o1, -415821600, 9743099, 4 tz.transition 1957, 4, :o2, -400093200, 58462963, 24 tz.transition 1957, 10, :o1, -384372000, 9744555, 4 tz.transition 1958, 4, :o2, -368643600, 58471699, 24 tz.transition 1958, 10, :o1, -352922400, 9746011, 4 tz.transition 1959, 4, :o2, -337194000, 58480435, 24 tz.transition 1959, 10, :o1, -321472800, 9747467, 4 tz.transition 1960, 4, :o2, -305744400, 58489171, 24 tz.transition 1960, 10, :o1, -289418400, 9748951, 4 tz.transition 1961, 4, :o2, -273690000, 58498075, 24 tz.transition 1961, 10, :o1, -257968800, 9750407, 4 tz.transition 1962, 4, :o2, -242240400, 58506811, 24 tz.transition 1962, 10, :o1, -226519200, 9751863, 4 tz.transition 1963, 4, :o2, -210790800, 58515547, 24 tz.transition 1963, 10, :o1, -195069600, 9753319, 4 tz.transition 1964, 4, :o2, -179341200, 58524283, 24 tz.transition 1964, 10, :o1, -163620000, 9754775, 4 tz.transition 1965, 4, :o2, -147891600, 58533019, 24 tz.transition 1965, 10, :o1, -131565600, 9756259, 4 tz.transition 1966, 4, :o2, -116442000, 58541755, 24 tz.transition 1966, 10, :o1, -100116000, 9757715, 4 tz.transition 1967, 4, :o2, -84387600, 58550659, 24 tz.transition 1967, 10, :o1, -68666400, 9759171, 4 tz.transition 1968, 4, :o2, -52938000, 58559395, 24 tz.transition 1968, 10, :o1, -37216800, 9760627, 4 tz.transition 1969, 4, :o2, -21488400, 58568131, 24 tz.transition 1969, 10, :o1, -5767200, 9762083, 4 tz.transition 1970, 4, :o2, 9961200 tz.transition 1970, 10, :o1, 25682400 tz.transition 1971, 4, :o2, 41410800 tz.transition 1971, 10, :o1, 57736800 tz.transition 1972, 4, :o2, 73465200 tz.transition 1972, 10, :o1, 89186400 tz.transition 1973, 4, :o2, 104914800 tz.transition 1973, 10, :o1, 120636000 tz.transition 1974, 1, :o2, 126687600 tz.transition 1974, 10, :o1, 152085600 tz.transition 1975, 2, :o2, 162370800 tz.transition 1975, 10, :o1, 183535200 tz.transition 1976, 4, :o2, 199263600 tz.transition 1976, 10, :o1, 215589600 tz.transition 1977, 4, :o2, 230713200 tz.transition 1977, 10, :o1, 247039200 tz.transition 1978, 4, :o2, 262767600 tz.transition 1978, 10, :o1, 278488800 tz.transition 1979, 4, :o2, 294217200 tz.transition 1979, 10, :o1, 309938400 tz.transition 1980, 4, :o2, 325666800 tz.transition 1980, 10, :o1, 341388000 tz.transition 1981, 4, :o2, 357116400 tz.transition 1981, 10, :o1, 372837600 tz.transition 1982, 4, :o2, 388566000 tz.transition 1982, 10, :o1, 404892000 tz.transition 1983, 4, :o2, 420015600 tz.transition 1983, 10, :o1, 436341600 tz.transition 1984, 4, :o2, 452070000 tz.transition 1984, 10, :o1, 467791200 tz.transition 1985, 4, :o2, 483519600 tz.transition 1985, 10, :o1, 499240800 tz.transition 1986, 4, :o2, 514969200 tz.transition 1986, 10, :o1, 530690400 tz.transition 1987, 4, :o2, 544604400 tz.transition 1987, 10, :o1, 562140000 tz.transition 1988, 4, :o2, 576054000 tz.transition 1988, 10, :o1, 594194400 tz.transition 1989, 4, :o2, 607503600 tz.transition 1989, 10, :o1, 625644000 tz.transition 1990, 4, :o2, 638953200 tz.transition 1990, 10, :o1, 657093600 tz.transition 1991, 4, :o2, 671007600 tz.transition 1991, 10, :o1, 688543200 tz.transition 1992, 4, :o2, 702457200 tz.transition 1992, 10, :o1, 719992800 tz.transition 1993, 4, :o2, 733906800 tz.transition 1993, 10, :o1, 752047200 tz.transition 1994, 4, :o2, 765356400 tz.transition 1994, 10, :o1, 783496800 tz.transition 1995, 4, :o2, 796806000 tz.transition 1995, 10, :o1, 814946400 tz.transition 1996, 4, :o2, 828860400 tz.transition 1996, 10, :o1, 846396000 tz.transition 1997, 4, :o2, 860310000 tz.transition 1997, 10, :o1, 877845600 tz.transition 1998, 4, :o2, 891759600 tz.transition 1998, 10, :o1, 909295200 tz.transition 1999, 4, :o2, 923209200 tz.transition 1999, 10, :o1, 941349600 tz.transition 2000, 4, :o2, 954658800 tz.transition 2000, 10, :o1, 972799200 tz.transition 2001, 4, :o2, 986108400 tz.transition 2001, 10, :o1, 1004248800 tz.transition 2002, 4, :o2, 1018162800 tz.transition 2002, 10, :o1, 1035698400 tz.transition 2003, 4, :o2, 1049612400 tz.transition 2003, 10, :o1, 1067148000 tz.transition 2004, 4, :o2, 1081062000 tz.transition 2004, 10, :o1, 1099202400 tz.transition 2005, 4, :o2, 1112511600 tz.transition 2005, 10, :o1, 1130652000 tz.transition 2006, 4, :o2, 1143961200 tz.transition 2006, 10, :o1, 1162101600 tz.transition 2007, 3, :o2, 1173596400 tz.transition 2007, 11, :o1, 1194156000 tz.transition 2008, 3, :o2, 1205046000 tz.transition 2008, 11, :o1, 1225605600 tz.transition 2009, 3, :o2, 1236495600 tz.transition 2009, 11, :o1, 1257055200 tz.transition 2010, 3, :o2, 1268550000 tz.transition 2010, 11, :o1, 1289109600 tz.transition 2011, 3, :o2, 1299999600 tz.transition 2011, 11, :o1, 1320559200 tz.transition 2012, 3, :o2, 1331449200 tz.transition 2012, 11, :o1, 1352008800 tz.transition 2013, 3, :o2, 1362898800 tz.transition 2013, 11, :o1, 1383458400 tz.transition 2014, 3, :o2, 1394348400 tz.transition 2014, 11, :o1, 1414908000 tz.transition 2015, 3, :o2, 1425798000 tz.transition 2015, 11, :o1, 1446357600 tz.transition 2016, 3, :o2, 1457852400 tz.transition 2016, 11, :o1, 1478412000 tz.transition 2017, 3, :o2, 1489302000 tz.transition 2017, 11, :o1, 1509861600 tz.transition 2018, 3, :o2, 1520751600 tz.transition 2018, 11, :o1, 1541311200 tz.transition 2019, 3, :o2, 1552201200 tz.transition 2019, 11, :o1, 1572760800 tz.transition 2020, 3, :o2, 1583650800 tz.transition 2020, 11, :o1, 1604210400 tz.transition 2021, 3, :o2, 1615705200 tz.transition 2021, 11, :o1, 1636264800 tz.transition 2022, 3, :o2, 1647154800 tz.transition 2022, 11, :o1, 1667714400 tz.transition 2023, 3, :o2, 1678604400 tz.transition 2023, 11, :o1, 1699164000 tz.transition 2024, 3, :o2, 1710054000 tz.transition 2024, 11, :o1, 1730613600 tz.transition 2025, 3, :o2, 1741503600 tz.transition 2025, 11, :o1, 1762063200 tz.transition 2026, 3, :o2, 1772953200 tz.transition 2026, 11, :o1, 1793512800 tz.transition 2027, 3, :o2, 1805007600 tz.transition 2027, 11, :o1, 1825567200 tz.transition 2028, 3, :o2, 1836457200 tz.transition 2028, 11, :o1, 1857016800 tz.transition 2029, 3, :o2, 1867906800 tz.transition 2029, 11, :o1, 1888466400 tz.transition 2030, 3, :o2, 1899356400 tz.transition 2030, 11, :o1, 1919916000 tz.transition 2031, 3, :o2, 1930806000 tz.transition 2031, 11, :o1, 1951365600 tz.transition 2032, 3, :o2, 1962860400 tz.transition 2032, 11, :o1, 1983420000 tz.transition 2033, 3, :o2, 1994310000 tz.transition 2033, 11, :o1, 2014869600 tz.transition 2034, 3, :o2, 2025759600 tz.transition 2034, 11, :o1, 2046319200 tz.transition 2035, 3, :o2, 2057209200 tz.transition 2035, 11, :o1, 2077768800 tz.transition 2036, 3, :o2, 2088658800 tz.transition 2036, 11, :o1, 2109218400 tz.transition 2037, 3, :o2, 2120108400 tz.transition 2037, 11, :o1, 2140668000 tz.transition 2038, 3, :o2, 2152162800, 59171923, 24 tz.transition 2038, 11, :o1, 2172722400, 9862939, 4 tz.transition 2039, 3, :o2, 2183612400, 59180659, 24 tz.transition 2039, 11, :o1, 2204172000, 9864395, 4 tz.transition 2040, 3, :o2, 2215062000, 59189395, 24 tz.transition 2040, 11, :o1, 2235621600, 9865851, 4 tz.transition 2041, 3, :o2, 2246511600, 59198131, 24 tz.transition 2041, 11, :o1, 2267071200, 9867307, 4 tz.transition 2042, 3, :o2, 2277961200, 59206867, 24 tz.transition 2042, 11, :o1, 2298520800, 9868763, 4 tz.transition 2043, 3, :o2, 2309410800, 59215603, 24 tz.transition 2043, 11, :o1, 2329970400, 9870219, 4 tz.transition 2044, 3, :o2, 2341465200, 59224507, 24 tz.transition 2044, 11, :o1, 2362024800, 9871703, 4 tz.transition 2045, 3, :o2, 2372914800, 59233243, 24 tz.transition 2045, 11, :o1, 2393474400, 9873159, 4 tz.transition 2046, 3, :o2, 2404364400, 59241979, 24 tz.transition 2046, 11, :o1, 2424924000, 9874615, 4 tz.transition 2047, 3, :o2, 2435814000, 59250715, 24 tz.transition 2047, 11, :o1, 2456373600, 9876071, 4 tz.transition 2048, 3, :o2, 2467263600, 59259451, 24 tz.transition 2048, 11, :o1, 2487823200, 9877527, 4 tz.transition 2049, 3, :o2, 2499318000, 59268355, 24 tz.transition 2049, 11, :o1, 2519877600, 9879011, 4 tz.transition 2050, 3, :o2, 2530767600, 59277091, 24 tz.transition 2050, 11, :o1, 2551327200, 9880467, 4 tz.transition 2051, 3, :o2, 2562217200, 59285827, 24 tz.transition 2051, 11, :o1, 2582776800, 9881923, 4 tz.transition 2052, 3, :o2, 2593666800, 59294563, 24 tz.transition 2052, 11, :o1, 2614226400, 9883379, 4 tz.transition 2053, 3, :o2, 2625116400, 59303299, 24 tz.transition 2053, 11, :o1, 2645676000, 9884835, 4 tz.transition 2054, 3, :o2, 2656566000, 59312035, 24 tz.transition 2054, 11, :o1, 2677125600, 9886291, 4 tz.transition 2055, 3, :o2, 2688620400, 59320939, 24 tz.transition 2055, 11, :o1, 2709180000, 9887775, 4 tz.transition 2056, 3, :o2, 2720070000, 59329675, 24 tz.transition 2056, 11, :o1, 2740629600, 9889231, 4 tz.transition 2057, 3, :o2, 2751519600, 59338411, 24 tz.transition 2057, 11, :o1, 2772079200, 9890687, 4 tz.transition 2058, 3, :o2, 2782969200, 59347147, 24 tz.transition 2058, 11, :o1, 2803528800, 9892143, 4 tz.transition 2059, 3, :o2, 2814418800, 59355883, 24 tz.transition 2059, 11, :o1, 2834978400, 9893599, 4 tz.transition 2060, 3, :o2, 2846473200, 59364787, 24 tz.transition 2060, 11, :o1, 2867032800, 9895083, 4 tz.transition 2061, 3, :o2, 2877922800, 59373523, 24 tz.transition 2061, 11, :o1, 2898482400, 9896539, 4 tz.transition 2062, 3, :o2, 2909372400, 59382259, 24 tz.transition 2062, 11, :o1, 2929932000, 9897995, 4 tz.transition 2063, 3, :o2, 2940822000, 59390995, 24 tz.transition 2063, 11, :o1, 2961381600, 9899451, 4 tz.transition 2064, 3, :o2, 2972271600, 59399731, 24 tz.transition 2064, 11, :o1, 2992831200, 9900907, 4 end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/EST.rb0000644000004100000410000000054612400401360023764 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module EST include TimezoneDefinition timezone 'EST' do |tz| tz.offset :o0, -18000, 0, :EST end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Etc/0000755000004100000410000000000012400401360023512 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__m__1.rb0000644000004100000410000000063712400401360025526 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Etc module GMT__m__1 include TimezoneDefinition timezone 'Etc/GMT-1' do |tz| tz.offset :o0, 3600, 0, :'GMT-1' end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Etc/GMT__p__1.rb0000644000004100000410000000064012400401360025523 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Etc module GMT__p__1 include TimezoneDefinition timezone 'Etc/GMT+1' do |tz| tz.offset :o0, -3600, 0, :'GMT+1' end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/Etc/UTC.rb0000644000004100000410000000062012400401360024470 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module Etc module UTC include TimezoneDefinition timezone 'Etc/UTC' do |tz| tz.offset :o0, 0, 0, :UTC end end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/definitions/UTC.rb0000644000004100000410000000046012400401360023757 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Definitions module UTC include TimezoneDefinition linked_timezone 'UTC', 'Etc/UTC' end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/indexes/0000755000004100000410000000000012400401360022123 5ustar www-datawww-datatzinfo-1.2.2/test/tzinfo-data/tzinfo/data/indexes/countries.rb0000644000004100000410000013001112400401360024457 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Indexes module Countries include CountryIndexDefinition country 'AD', 'Andorra' do |c| c.timezone 'Europe/Andorra', 85, 2, 91, 60 end country 'AE', 'United Arab Emirates' do |c| c.timezone 'Asia/Dubai', 253, 10, 553, 10 end country 'AF', 'Afghanistan' do |c| c.timezone 'Asia/Kabul', 2071, 60, 346, 5 end country 'AG', 'Antigua & Barbuda' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'AI', 'Anguilla' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'AL', 'Albania' do |c| c.timezone 'Europe/Tirane', 124, 3, 119, 6 end country 'AM', 'Armenia' do |c| c.timezone 'Asia/Yerevan', 2411, 60, 89, 2 end country 'AO', 'Angola' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'AQ', 'Antarctica' do |c| c.timezone 'Antarctica/Rothera', -2027, 30, -1022, 15, 'Rothera Station, Adelaide Island' c.timezone 'Antarctica/Palmer', -324, 5, -641, 10, 'Palmer Station, Anvers Island' c.timezone 'Antarctica/Mawson', -338, 5, 3773, 60, 'Mawson Station, Holme Bay' c.timezone 'Antarctica/Davis', -823, 12, 2339, 30, 'Davis Station, Vestfold Hills' c.timezone 'Antarctica/Casey', -3977, 60, 6631, 60, 'Casey Station, Bailey Peninsula' c.timezone 'Antarctica/Vostok', -392, 5, 1069, 10, 'Vostok Station, Lake Vostok' c.timezone 'Antarctica/DumontDUrville', -200, 3, 8401, 60, 'Dumont-d\'Urville Station, Terre Adelie' c.timezone 'Antarctica/Syowa', -124211, 1800, 3959, 100, 'Syowa Station, E Ongul I' c.timezone 'Antarctica/Troll', -259241, 3600, 507, 200, 'Troll Station, Queen Maud Land' c.timezone 'Pacific/Auckland', -553, 15, 5243, 30, 'New Zealand time' end country 'AR', 'Argentina' do |c| c.timezone 'America/Argentina/Buenos_Aires', -173, 5, -1169, 20, 'Buenos Aires (BA, CF)' c.timezone 'America/Argentina/Cordoba', -157, 5, -3851, 60, 'most locations (CB, CC, CN, ER, FM, MN, SE, SF)' c.timezone 'America/Argentina/Salta', -1487, 60, -785, 12, '(SA, LP, NQ, RN)' c.timezone 'America/Argentina/Jujuy', -1451, 60, -653, 10, 'Jujuy (JY)' c.timezone 'America/Argentina/Tucuman', -1609, 60, -3913, 60, 'Tucumán (TM)' c.timezone 'America/Argentina/Catamarca', -427, 15, -3947, 60, 'Catamarca (CT), Chubut (CH)' c.timezone 'America/Argentina/La_Rioja', -883, 30, -1337, 20, 'La Rioja (LR)' c.timezone 'America/Argentina/San_Juan', -473, 15, -4111, 60, 'San Juan (SJ)' c.timezone 'America/Argentina/Mendoza', -1973, 60, -4129, 60, 'Mendoza (MZ)' c.timezone 'America/Argentina/San_Luis', -1999, 60, -1327, 20, 'San Luis (SL)' c.timezone 'America/Argentina/Rio_Gallegos', -1549, 30, -4153, 60, 'Santa Cruz (SC)' c.timezone 'America/Argentina/Ushuaia', -274, 5, -683, 10, 'Tierra del Fuego (TF)' end country 'AS', 'Samoa (American)' do |c| c.timezone 'Pacific/Pago_Pago', -214, 15, -1707, 10, 'Samoa, Midway' end country 'AT', 'Austria' do |c| c.timezone 'Europe/Vienna', 2893, 60, 49, 3 end country 'AU', 'Australia' do |c| c.timezone 'Australia/Lord_Howe', -631, 20, 1909, 12, 'Lord Howe Island' c.timezone 'Antarctica/Macquarie', -109, 2, 3179, 20, 'Macquarie Island' c.timezone 'Australia/Hobart', -2573, 60, 8839, 60, 'Tasmania - most locations' c.timezone 'Australia/Currie', -599, 15, 2158, 15, 'Tasmania - King Island' c.timezone 'Australia/Melbourne', -2269, 60, 4349, 30, 'Victoria' c.timezone 'Australia/Sydney', -508, 15, 9073, 60, 'New South Wales - most locations' c.timezone 'Australia/Broken_Hill', -639, 20, 2829, 20, 'New South Wales - Yancowinna' c.timezone 'Australia/Brisbane', -412, 15, 4591, 30, 'Queensland - most locations' c.timezone 'Australia/Lindeman', -304, 15, 149, 1, 'Queensland - Holiday Islands' c.timezone 'Australia/Adelaide', -419, 12, 1663, 12, 'South Australia' c.timezone 'Australia/Darwin', -187, 15, 785, 6, 'Northern Territory' c.timezone 'Australia/Perth', -639, 20, 2317, 20, 'Western Australia - most locations' c.timezone 'Australia/Eucla', -1903, 60, 1933, 15, 'Western Australia - Eucla area' end country 'AW', 'Aruba' do |c| c.timezone 'America/Curacao', 731, 60, -69, 1 end country 'AX', 'Aaland Islands' do |c| c.timezone 'Europe/Helsinki', 361, 6, 749, 30 end country 'AZ', 'Azerbaijan' do |c| c.timezone 'Asia/Baku', 2423, 60, 997, 20 end country 'BA', 'Bosnia & Herzegovina' do |c| c.timezone 'Europe/Belgrade', 269, 6, 41, 2 end country 'BB', 'Barbados' do |c| c.timezone 'America/Barbados', 131, 10, -3577, 60 end country 'BD', 'Bangladesh' do |c| c.timezone 'Asia/Dhaka', 1423, 60, 1085, 12 end country 'BE', 'Belgium' do |c| c.timezone 'Europe/Brussels', 305, 6, 13, 3 end country 'BF', 'Burkina Faso' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'BG', 'Bulgaria' do |c| c.timezone 'Europe/Sofia', 2561, 60, 1399, 60 end country 'BH', 'Bahrain' do |c| c.timezone 'Asia/Qatar', 1517, 60, 773, 15 end country 'BI', 'Burundi' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end country 'BJ', 'Benin' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'BL', 'St Barthelemy' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'BM', 'Bermuda' do |c| c.timezone 'Atlantic/Bermuda', 1937, 60, -1943, 30 end country 'BN', 'Brunei' do |c| c.timezone 'Asia/Brunei', 74, 15, 1379, 12 end country 'BO', 'Bolivia' do |c| c.timezone 'America/La_Paz', -33, 2, -1363, 20 end country 'BQ', 'Caribbean Netherlands' do |c| c.timezone 'America/Curacao', 731, 60, -69, 1 end country 'BR', 'Brazil' do |c| c.timezone 'America/Noronha', -77, 20, -389, 12, 'Atlantic islands' c.timezone 'America/Belem', -29, 20, -2909, 60, 'Amapá, E Pará' c.timezone 'America/Fortaleza', -223, 60, -77, 2, 'NE Brazil (MA, PI, CE, RN, PB)' c.timezone 'America/Recife', -161, 20, -349, 10, 'Pernambuco' c.timezone 'America/Araguaina', -36, 5, -241, 5, 'Tocantins' c.timezone 'America/Maceio', -29, 3, -2143, 60, 'Alagoas, Sergipe' c.timezone 'America/Bahia', -779, 60, -2311, 60, 'Bahia' c.timezone 'America/Sao_Paulo', -353, 15, -2797, 60, 'S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)' c.timezone 'America/Campo_Grande', -409, 20, -3277, 60, 'Mato Grosso do Sul' c.timezone 'America/Cuiaba', -187, 12, -673, 12, 'Mato Grosso' c.timezone 'America/Santarem', -73, 30, -823, 15, 'W Pará' c.timezone 'America/Porto_Velho', -263, 30, -639, 10, 'Rondônia' c.timezone 'America/Boa_Vista', 169, 60, -182, 3, 'Roraima' c.timezone 'America/Manaus', -47, 15, -3601, 60, 'E Amazonas' c.timezone 'America/Eirunepe', -20, 3, -1048, 15, 'W Amazonas' c.timezone 'America/Rio_Branco', -299, 30, -339, 5, 'Acre' end country 'BS', 'Bahamas' do |c| c.timezone 'America/Nassau', 301, 12, -1547, 20 end country 'BT', 'Bhutan' do |c| c.timezone 'Asia/Thimphu', 412, 15, 1793, 20 end country 'BV', 'Bouvet Island' country 'BW', 'Botswana' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end country 'BY', 'Belarus' do |c| c.timezone 'Europe/Minsk', 539, 10, 827, 30 end country 'BZ', 'Belize' do |c| c.timezone 'America/Belize', 35, 2, -441, 5 end country 'CA', 'Canada' do |c| c.timezone 'America/St_Johns', 1427, 30, -3163, 60, 'Newfoundland Time, including SE Labrador' c.timezone 'America/Halifax', 893, 20, -318, 5, 'Atlantic Time - Nova Scotia (most places), PEI' c.timezone 'America/Glace_Bay', 231, 5, -1199, 20, 'Atlantic Time - Nova Scotia - places that did not observe DST 1966-1971' c.timezone 'America/Moncton', 461, 10, -3887, 60, 'Atlantic Time - New Brunswick' c.timezone 'America/Goose_Bay', 160, 3, -725, 12, 'Atlantic Time - Labrador - most locations' c.timezone 'America/Blanc-Sablon', 617, 12, -3427, 60, 'Atlantic Standard Time - Quebec - Lower North Shore' c.timezone 'America/Toronto', 873, 20, -4763, 60, 'Eastern Time - Ontario & Quebec - most locations' c.timezone 'America/Nipigon', 2941, 60, -1324, 15, 'Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973' c.timezone 'America/Thunder_Bay', 2903, 60, -357, 4, 'Eastern Time - Thunder Bay, Ontario' c.timezone 'America/Iqaluit', 956, 15, -1027, 15, 'Eastern Time - east Nunavut - most locations' c.timezone 'America/Pangnirtung', 992, 15, -986, 15, 'Eastern Time - Pangnirtung, Nunavut' c.timezone 'America/Resolute', 33613, 450, -22759, 240, 'Central Time - Resolute, Nunavut' c.timezone 'America/Atikokan', 175531, 3600, -54973, 600, 'Eastern Standard Time - Atikokan, Ontario and Southampton I, Nunavut' c.timezone 'America/Rankin_Inlet', 3769, 60, -331499, 3600, 'Central Time - central Nunavut' c.timezone 'America/Winnipeg', 2993, 60, -1943, 20, 'Central Time - Manitoba & west Ontario' c.timezone 'America/Rainy_River', 2923, 60, -2837, 30, 'Central Time - Rainy River & Fort Frances, Ontario' c.timezone 'America/Regina', 252, 5, -2093, 20, 'Central Standard Time - Saskatchewan - most locations' c.timezone 'America/Swift_Current', 3017, 60, -647, 6, 'Central Standard Time - Saskatchewan - midwest' c.timezone 'America/Edmonton', 1071, 20, -1702, 15, 'Mountain Time - Alberta, east British Columbia & west Saskatchewan' c.timezone 'America/Cambridge_Bay', 24881, 360, -37819, 360, 'Mountain Time - west Nunavut' c.timezone 'America/Yellowknife', 1249, 20, -2287, 20, 'Mountain Time - central Northwest Territories' c.timezone 'America/Inuvik', 246059, 3600, -8023, 60, 'Mountain Time - west Northwest Territories' c.timezone 'America/Creston', 491, 10, -6991, 60, 'Mountain Standard Time - Creston, British Columbia' c.timezone 'America/Dawson_Creek', 1793, 30, -3607, 30, 'Mountain Standard Time - Dawson Creek & Fort Saint John, British Columbia' c.timezone 'America/Vancouver', 739, 15, -7387, 60, 'Pacific Time - west British Columbia' c.timezone 'America/Whitehorse', 3643, 60, -2701, 20, 'Pacific Time - south Yukon' c.timezone 'America/Dawson', 961, 15, -1673, 12, 'Pacific Time - north Yukon' end country 'CC', 'Cocos (Keeling) Islands' do |c| c.timezone 'Indian/Cocos', -73, 6, 1163, 12 end country 'CD', 'Congo (Dem. Rep.)' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'CF', 'Central African Rep.' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'CG', 'Congo (Rep.)' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'CH', 'Switzerland' do |c| c.timezone 'Europe/Zurich', 2843, 60, 128, 15, 'Swiss time' end country 'CI', 'Cote d\'Ivoire' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'CK', 'Cook Islands' do |c| c.timezone 'Pacific/Rarotonga', -637, 30, -4793, 30 end country 'CL', 'Chile' do |c| c.timezone 'America/Santiago', -669, 20, -212, 3, 'most locations' c.timezone 'Pacific/Easter', -543, 20, -3283, 30, 'Easter Island' end country 'CM', 'Cameroon' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'CN', 'China' do |c| c.timezone 'Asia/Shanghai', 937, 30, 1822, 15, 'Beijing Time' c.timezone 'Asia/Urumqi', 219, 5, 1051, 12, 'Xinjiang Time' end country 'CO', 'Colombia' do |c| c.timezone 'America/Bogota', 23, 5, -889, 12 end country 'CR', 'Costa Rica' do |c| c.timezone 'America/Costa_Rica', 149, 15, -1009, 12 end country 'CU', 'Cuba' do |c| c.timezone 'America/Havana', 347, 15, -2471, 30 end country 'CV', 'Cape Verde' do |c| c.timezone 'Atlantic/Cape_Verde', 179, 12, -1411, 60 end country 'CW', 'Curacao' do |c| c.timezone 'America/Curacao', 731, 60, -69, 1 end country 'CX', 'Christmas Island' do |c| c.timezone 'Indian/Christmas', -125, 12, 6343, 60 end country 'CY', 'Cyprus' do |c| c.timezone 'Asia/Nicosia', 211, 6, 1001, 30 end country 'CZ', 'Czech Republic' do |c| c.timezone 'Europe/Prague', 601, 12, 433, 30 end country 'DE', 'Germany' do |c| c.timezone 'Europe/Berlin', 105, 2, 401, 30, 'Berlin time' c.timezone 'Europe/Zurich', 2843, 60, 128, 15, 'Swiss time' end country 'DJ', 'Djibouti' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'DK', 'Denmark' do |c| c.timezone 'Europe/Copenhagen', 167, 3, 151, 12 end country 'DM', 'Dominica' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'DO', 'Dominican Republic' do |c| c.timezone 'America/Santo_Domingo', 277, 15, -699, 10 end country 'DZ', 'Algeria' do |c| c.timezone 'Africa/Algiers', 2207, 60, 61, 20 end country 'EC', 'Ecuador' do |c| c.timezone 'America/Guayaquil', -13, 6, -479, 6, 'mainland' c.timezone 'Pacific/Galapagos', -9, 10, -448, 5, 'Galápagos Islands' end country 'EE', 'Estonia' do |c| c.timezone 'Europe/Tallinn', 713, 12, 99, 4 end country 'EG', 'Egypt' do |c| c.timezone 'Africa/Cairo', 601, 20, 125, 4 end country 'EH', 'Western Sahara' do |c| c.timezone 'Africa/El_Aaiun', 543, 20, -66, 5 end country 'ER', 'Eritrea' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'ES', 'Spain' do |c| c.timezone 'Europe/Madrid', 202, 5, -221, 60, 'mainland' c.timezone 'Africa/Ceuta', 2153, 60, -319, 60, 'Ceuta & Melilla' c.timezone 'Atlantic/Canary', 281, 10, -77, 5, 'Canary Islands' end country 'ET', 'Ethiopia' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'FI', 'Finland' do |c| c.timezone 'Europe/Helsinki', 361, 6, 749, 30 end country 'FJ', 'Fiji' do |c| c.timezone 'Pacific/Fiji', -272, 15, 2141, 12 end country 'FK', 'Falkland Islands' do |c| c.timezone 'Atlantic/Stanley', -517, 10, -1157, 20 end country 'FM', 'Micronesia' do |c| c.timezone 'Pacific/Chuuk', 89, 12, 9107, 60, 'Chuuk (Truk) and Yap' c.timezone 'Pacific/Pohnpei', 209, 30, 9493, 60, 'Pohnpei (Ponape)' c.timezone 'Pacific/Kosrae', 319, 60, 9779, 60, 'Kosrae' end country 'FO', 'Faroe Islands' do |c| c.timezone 'Atlantic/Faroe', 3721, 60, -203, 30 end country 'FR', 'France' do |c| c.timezone 'Europe/Paris', 733, 15, 7, 3 end country 'GA', 'Gabon' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'GB', 'Britain (UK)' do |c| c.timezone 'Europe/London', 6181, 120, -451, 3600 end country 'GD', 'Grenada' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'GE', 'Georgia' do |c| c.timezone 'Asia/Tbilisi', 2503, 60, 2689, 60 end country 'GF', 'French Guiana' do |c| c.timezone 'America/Cayenne', 74, 15, -157, 3 end country 'GG', 'Guernsey' do |c| c.timezone 'Europe/London', 6181, 120, -451, 3600 end country 'GH', 'Ghana' do |c| c.timezone 'Africa/Accra', 111, 20, -13, 60 end country 'GI', 'Gibraltar' do |c| c.timezone 'Europe/Gibraltar', 542, 15, -107, 20 end country 'GL', 'Greenland' do |c| c.timezone 'America/Godthab', 3851, 60, -776, 15, 'most locations' c.timezone 'America/Danmarkshavn', 2303, 30, -56, 3, 'east coast, north of Scoresbysund' c.timezone 'America/Scoresbysund', 4229, 60, -659, 30, 'Scoresbysund / Ittoqqortoormiit' c.timezone 'America/Thule', 2297, 30, -4127, 60, 'Thule / Pituffik' end country 'GM', 'Gambia' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'GN', 'Guinea' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'GP', 'Guadeloupe' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'GQ', 'Equatorial Guinea' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'GR', 'Greece' do |c| c.timezone 'Europe/Athens', 1139, 30, 1423, 60 end country 'GS', 'South Georgia & the South Sandwich Islands' do |c| c.timezone 'Atlantic/South_Georgia', -814, 15, -548, 15 end country 'GT', 'Guatemala' do |c| c.timezone 'America/Guatemala', 439, 30, -5431, 60 end country 'GU', 'Guam' do |c| c.timezone 'Pacific/Guam', 202, 15, 579, 4 end country 'GW', 'Guinea-Bissau' do |c| c.timezone 'Africa/Bissau', 237, 20, -187, 12 end country 'GY', 'Guyana' do |c| c.timezone 'America/Guyana', 34, 5, -349, 6 end country 'HK', 'Hong Kong' do |c| c.timezone 'Asia/Hong_Kong', 1337, 60, 2283, 20 end country 'HM', 'Heard Island & McDonald Islands' country 'HN', 'Honduras' do |c| c.timezone 'America/Tegucigalpa', 141, 10, -5233, 60 end country 'HR', 'Croatia' do |c| c.timezone 'Europe/Belgrade', 269, 6, 41, 2 end country 'HT', 'Haiti' do |c| c.timezone 'America/Port-au-Prince', 278, 15, -217, 3 end country 'HU', 'Hungary' do |c| c.timezone 'Europe/Budapest', 95, 2, 229, 12 end country 'ID', 'Indonesia' do |c| c.timezone 'Asia/Jakarta', -37, 6, 534, 5, 'Java & Sumatra' c.timezone 'Asia/Pontianak', -1, 30, 328, 3, 'west & central Borneo' c.timezone 'Asia/Makassar', -307, 60, 597, 5, 'east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor' c.timezone 'Asia/Jayapura', -38, 15, 1407, 10, 'west New Guinea (Irian Jaya) & Malukus (Moluccas)' end country 'IE', 'Ireland' do |c| c.timezone 'Europe/Dublin', 160, 3, -25, 4 end country 'IL', 'Israel' do |c| c.timezone 'Asia/Jerusalem', 11441, 360, 63403, 1800 end country 'IM', 'Isle of Man' do |c| c.timezone 'Europe/London', 6181, 120, -451, 3600 end country 'IN', 'India' do |c| c.timezone 'Asia/Kolkata', 338, 15, 2651, 30 end country 'IO', 'British Indian Ocean Territory' do |c| c.timezone 'Indian/Chagos', -22, 3, 869, 12 end country 'IQ', 'Iraq' do |c| c.timezone 'Asia/Baghdad', 667, 20, 533, 12 end country 'IR', 'Iran' do |c| c.timezone 'Asia/Tehran', 107, 3, 1543, 30 end country 'IS', 'Iceland' do |c| c.timezone 'Atlantic/Reykjavik', 1283, 20, -437, 20 end country 'IT', 'Italy' do |c| c.timezone 'Europe/Rome', 419, 10, 749, 60 end country 'JE', 'Jersey' do |c| c.timezone 'Europe/London', 6181, 120, -451, 3600 end country 'JM', 'Jamaica' do |c| c.timezone 'America/Jamaica', 12937, 720, -11519, 150 end country 'JO', 'Jordan' do |c| c.timezone 'Asia/Amman', 639, 20, 539, 15 end country 'JP', 'Japan' do |c| c.timezone 'Asia/Tokyo', 32089, 900, 503081, 3600 end country 'KE', 'Kenya' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'KG', 'Kyrgyzstan' do |c| c.timezone 'Asia/Bishkek', 429, 10, 373, 5 end country 'KH', 'Cambodia' do |c| c.timezone 'Asia/Bangkok', 55, 4, 6031, 60 end country 'KI', 'Kiribati' do |c| c.timezone 'Pacific/Tarawa', 17, 12, 173, 1, 'Gilbert Islands' c.timezone 'Pacific/Enderbury', -47, 15, -2053, 12, 'Phoenix Islands' c.timezone 'Pacific/Kiritimati', 28, 15, -472, 3, 'Line Islands' end country 'KM', 'Comoros' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'KN', 'St Kitts & Nevis' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'KP', 'Korea (North)' do |c| c.timezone 'Asia/Pyongyang', 2341, 60, 503, 4 end country 'KR', 'Korea (South)' do |c| c.timezone 'Asia/Seoul', 751, 20, 3809, 30 end country 'KW', 'Kuwait' do |c| c.timezone 'Asia/Riyadh', 739, 30, 2803, 60 end country 'KY', 'Cayman Islands' do |c| c.timezone 'America/Panama', 269, 30, -1193, 15 end country 'KZ', 'Kazakhstan' do |c| c.timezone 'Asia/Almaty', 173, 4, 1539, 20, 'most locations' c.timezone 'Asia/Qyzylorda', 224, 5, 982, 15, 'Qyzylorda (Kyzylorda, Kzyl-Orda)' c.timezone 'Asia/Aqtobe', 3017, 60, 343, 6, 'Aqtobe (Aktobe)' c.timezone 'Asia/Aqtau', 2671, 60, 754, 15, 'Atyrau (Atirau, Gur\'yev), Mangghystau (Mankistau)' c.timezone 'Asia/Oral', 3073, 60, 1027, 20, 'West Kazakhstan' end country 'LA', 'Laos' do |c| c.timezone 'Asia/Bangkok', 55, 4, 6031, 60 end country 'LB', 'Lebanon' do |c| c.timezone 'Asia/Beirut', 2033, 60, 71, 2 end country 'LC', 'St Lucia' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'LI', 'Liechtenstein' do |c| c.timezone 'Europe/Zurich', 2843, 60, 128, 15, 'Swiss time' end country 'LK', 'Sri Lanka' do |c| c.timezone 'Asia/Colombo', 104, 15, 1597, 20 end country 'LR', 'Liberia' do |c| c.timezone 'Africa/Monrovia', 63, 10, -647, 60 end country 'LS', 'Lesotho' do |c| c.timezone 'Africa/Johannesburg', -105, 4, 28, 1 end country 'LT', 'Lithuania' do |c| c.timezone 'Europe/Vilnius', 3281, 60, 1519, 60 end country 'LU', 'Luxembourg' do |c| c.timezone 'Europe/Luxembourg', 248, 5, 123, 20 end country 'LV', 'Latvia' do |c| c.timezone 'Europe/Riga', 1139, 20, 241, 10 end country 'LY', 'Libya' do |c| c.timezone 'Africa/Tripoli', 329, 10, 791, 60 end country 'MA', 'Morocco' do |c| c.timezone 'Africa/Casablanca', 673, 20, -91, 12 end country 'MC', 'Monaco' do |c| c.timezone 'Europe/Monaco', 437, 10, 443, 60 end country 'MD', 'Moldova' do |c| c.timezone 'Europe/Chisinau', 47, 1, 173, 6 end country 'ME', 'Montenegro' do |c| c.timezone 'Europe/Belgrade', 269, 6, 41, 2 end country 'MF', 'St Martin (French part)' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'MG', 'Madagascar' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'MH', 'Marshall Islands' do |c| c.timezone 'Pacific/Majuro', 143, 20, 856, 5, 'most locations' c.timezone 'Pacific/Kwajalein', 109, 12, 502, 3, 'Kwajalein' end country 'MK', 'Macedonia' do |c| c.timezone 'Europe/Belgrade', 269, 6, 41, 2 end country 'ML', 'Mali' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'MM', 'Myanmar (Burma)' do |c| c.timezone 'Asia/Rangoon', 1007, 60, 577, 6 end country 'MN', 'Mongolia' do |c| c.timezone 'Asia/Ulaanbaatar', 575, 12, 6413, 60, 'most locations' c.timezone 'Asia/Hovd', 2881, 60, 1833, 20, 'Bayan-Ölgii, Govi-Altai, Hovd, Uvs, Zavkhan' c.timezone 'Asia/Choibalsan', 721, 15, 229, 2, 'Dornod, Sükhbaatar' end country 'MO', 'Macau' do |c| c.timezone 'Asia/Macau', 667, 30, 1363, 12 end country 'MP', 'Northern Mariana Islands' do |c| c.timezone 'Pacific/Guam', 202, 15, 579, 4 end country 'MQ', 'Martinique' do |c| c.timezone 'America/Martinique', 73, 5, -733, 12 end country 'MR', 'Mauritania' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'MS', 'Montserrat' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'MT', 'Malta' do |c| c.timezone 'Europe/Malta', 359, 10, 871, 60 end country 'MU', 'Mauritius' do |c| c.timezone 'Indian/Mauritius', -121, 6, 115, 2 end country 'MV', 'Maldives' do |c| c.timezone 'Indian/Maldives', 25, 6, 147, 2 end country 'MW', 'Malawi' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end country 'MX', 'Mexico' do |c| c.timezone 'America/Mexico_City', 97, 5, -1983, 20, 'Central Time - most locations' c.timezone 'America/Cancun', 253, 12, -2603, 30, 'Central Time - Quintana Roo' c.timezone 'America/Merida', 629, 30, -5377, 60, 'Central Time - Campeche, Yucatán' c.timezone 'America/Monterrey', 77, 3, -6019, 60, 'Mexican Central Time - Coahuila, Durango, Nuevo León, Tamaulipas away from US border' c.timezone 'America/Matamoros', 155, 6, -195, 2, 'US Central Time - Coahuila, Durango, Nuevo León, Tamaulipas near US border' c.timezone 'America/Mazatlan', 1393, 60, -1277, 12, 'Mountain Time - S Baja, Nayarit, Sinaloa' c.timezone 'America/Chihuahua', 859, 30, -1273, 12, 'Mexican Mountain Time - Chihuahua away from US border' c.timezone 'America/Ojinaga', 887, 30, -1253, 12, 'US Mountain Time - Chihuahua near US border' c.timezone 'America/Hermosillo', 436, 15, -3329, 30, 'Mountain Standard Time - Sonora' c.timezone 'America/Tijuana', 488, 15, -7021, 60, 'US Pacific Time - Baja California near US border' c.timezone 'America/Santa_Isabel', 303, 10, -1723, 15, 'Mexican Pacific Time - Baja California away from US border' c.timezone 'America/Bahia_Banderas', 104, 5, -421, 4, 'Mexican Central Time - Bahía de Banderas' end country 'MY', 'Malaysia' do |c| c.timezone 'Asia/Kuala_Lumpur', 19, 6, 1017, 10, 'peninsular Malaysia' c.timezone 'Asia/Kuching', 31, 20, 331, 3, 'Sabah & Sarawak' end country 'MZ', 'Mozambique' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end country 'NA', 'Namibia' do |c| c.timezone 'Africa/Windhoek', -677, 30, 171, 10 end country 'NC', 'New Caledonia' do |c| c.timezone 'Pacific/Noumea', -334, 15, 3329, 20 end country 'NE', 'Niger' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'NF', 'Norfolk Island' do |c| c.timezone 'Pacific/Norfolk', -581, 20, 5039, 30 end country 'NG', 'Nigeria' do |c| c.timezone 'Africa/Lagos', 129, 20, 17, 5, 'West Africa Time (UTC+1)' end country 'NI', 'Nicaragua' do |c| c.timezone 'America/Managua', 243, 20, -5177, 60 end country 'NL', 'Netherlands' do |c| c.timezone 'Europe/Amsterdam', 1571, 30, 49, 10 end country 'NO', 'Norway' do |c| c.timezone 'Europe/Oslo', 719, 12, 43, 4 end country 'NP', 'Nepal' do |c| c.timezone 'Asia/Kathmandu', 1663, 60, 5119, 60 end country 'NR', 'Nauru' do |c| c.timezone 'Pacific/Nauru', -31, 60, 2003, 12 end country 'NU', 'Niue' do |c| c.timezone 'Pacific/Niue', -1141, 60, -2039, 12 end country 'NZ', 'New Zealand' do |c| c.timezone 'Pacific/Auckland', -553, 15, 5243, 30, 'New Zealand time' c.timezone 'Pacific/Chatham', -879, 20, -3531, 20, 'Chatham Islands' end country 'OM', 'Oman' do |c| c.timezone 'Asia/Dubai', 253, 10, 553, 10 end country 'PA', 'Panama' do |c| c.timezone 'America/Panama', 269, 30, -1193, 15 end country 'PE', 'Peru' do |c| c.timezone 'America/Lima', -241, 20, -1541, 20 end country 'PF', 'French Polynesia' do |c| c.timezone 'Pacific/Tahiti', -263, 15, -4487, 30, 'Society Islands' c.timezone 'Pacific/Marquesas', -9, 1, -279, 2, 'Marquesas Islands' c.timezone 'Pacific/Gambier', -347, 15, -2699, 20, 'Gambier Islands' end country 'PG', 'Papua New Guinea' do |c| c.timezone 'Pacific/Port_Moresby', -19, 2, 883, 6 end country 'PH', 'Philippines' do |c| c.timezone 'Asia/Manila', 175, 12, 121, 1 end country 'PK', 'Pakistan' do |c| c.timezone 'Asia/Karachi', 373, 15, 1341, 20 end country 'PL', 'Poland' do |c| c.timezone 'Europe/Warsaw', 209, 4, 21, 1 end country 'PM', 'St Pierre & Miquelon' do |c| c.timezone 'America/Miquelon', 941, 20, -169, 3 end country 'PN', 'Pitcairn' do |c| c.timezone 'Pacific/Pitcairn', -376, 15, -1561, 12 end country 'PR', 'Puerto Rico' do |c| c.timezone 'America/Puerto_Rico', 11081, 600, -118991, 1800 end country 'PS', 'Palestine' do |c| c.timezone 'Asia/Gaza', 63, 2, 517, 15, 'Gaza Strip' c.timezone 'Asia/Hebron', 473, 15, 7019, 200, 'West Bank' end country 'PT', 'Portugal' do |c| c.timezone 'Europe/Lisbon', 2323, 60, -137, 15, 'mainland' c.timezone 'Atlantic/Madeira', 979, 30, -169, 10, 'Madeira Islands' c.timezone 'Atlantic/Azores', 566, 15, -77, 3, 'Azores' end country 'PW', 'Palau' do |c| c.timezone 'Pacific/Palau', 22, 3, 8069, 60 end country 'PY', 'Paraguay' do |c| c.timezone 'America/Asuncion', -379, 15, -173, 3 end country 'QA', 'Qatar' do |c| c.timezone 'Asia/Qatar', 1517, 60, 773, 15 end country 'RE', 'Reunion' do |c| c.timezone 'Indian/Reunion', -313, 15, 832, 15, 'Réunion, Crozet Is, Scattered Is' end country 'RO', 'Romania' do |c| c.timezone 'Europe/Bucharest', 1333, 30, 261, 10 end country 'RS', 'Serbia' do |c| c.timezone 'Europe/Belgrade', 269, 6, 41, 2 end country 'RU', 'Russia' do |c| c.timezone 'Europe/Kaliningrad', 3283, 60, 41, 2, 'Moscow-01 - Kaliningrad' c.timezone 'Europe/Moscow', 66907, 1200, 8464, 225, 'Moscow+00 - west Russia' c.timezone 'Europe/Simferopol', 899, 20, 341, 10, 'Moscow+00 - Crimea' c.timezone 'Europe/Volgograd', 731, 15, 533, 12, 'Moscow+00 - Caspian Sea' c.timezone 'Europe/Samara', 266, 5, 1003, 20, 'Moscow+00 (Moscow+01 after 2014-10-26) - Samara, Udmurtia' c.timezone 'Asia/Yekaterinburg', 1137, 20, 303, 5, 'Moscow+02 - Urals' c.timezone 'Asia/Omsk', 55, 1, 367, 5, 'Moscow+03 - west Siberia' c.timezone 'Asia/Novosibirsk', 1651, 30, 995, 12, 'Moscow+03 - Novosibirsk' c.timezone 'Asia/Novokuznetsk', 215, 4, 5227, 60, 'Moscow+03 (Moscow+04 after 2014-10-26) - Kemerovo' c.timezone 'Asia/Krasnoyarsk', 3361, 60, 557, 6, 'Moscow+04 - Yenisei River' c.timezone 'Asia/Irkutsk', 784, 15, 313, 3, 'Moscow+05 - Lake Baikal' c.timezone 'Asia/Chita', 1041, 20, 1702, 15, 'Moscow+06 (Moscow+05 after 2014-10-26) - Zabaykalsky' c.timezone 'Asia/Yakutsk', 62, 1, 389, 3, 'Moscow+06 - Lena River' c.timezone 'Asia/Khandyga', 225563, 3600, 243997, 1800, 'Moscow+06 - Tomponsky, Ust-Maysky' c.timezone 'Asia/Vladivostok', 259, 6, 1979, 15, 'Moscow+07 - Amur River' c.timezone 'Asia/Sakhalin', 1409, 30, 1427, 10, 'Moscow+07 - Sakhalin Island' c.timezone 'Asia/Ust-Nera', 232417, 3600, 10742, 75, 'Moscow+07 - Oymyakonsky' c.timezone 'Asia/Magadan', 1787, 30, 754, 5, 'Moscow+08 (Moscow+07 after 2014-10-26) - Magadan' c.timezone 'Asia/Srednekolymsk', 1012, 15, 9223, 60, 'Moscow+08 - E Sakha, N Kuril Is' c.timezone 'Asia/Kamchatka', 3181, 60, 3173, 20, 'Moscow+08 (Moscow+09 after 2014-10-26) - Kamchatka' c.timezone 'Asia/Anadyr', 259, 4, 10649, 60, 'Moscow+08 (Moscow+09 after 2014-10-26) - Bering Sea' end country 'RW', 'Rwanda' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end country 'SA', 'Saudi Arabia' do |c| c.timezone 'Asia/Riyadh', 739, 30, 2803, 60 end country 'SB', 'Solomon Islands' do |c| c.timezone 'Pacific/Guadalcanal', -143, 15, 801, 5 end country 'SC', 'Seychelles' do |c| c.timezone 'Indian/Mahe', -14, 3, 832, 15 end country 'SD', 'Sudan' do |c| c.timezone 'Africa/Khartoum', 78, 5, 488, 15 end country 'SE', 'Sweden' do |c| c.timezone 'Europe/Stockholm', 178, 3, 361, 20 end country 'SG', 'Singapore' do |c| c.timezone 'Asia/Singapore', 77, 60, 2077, 20 end country 'SH', 'St Helena' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'SI', 'Slovenia' do |c| c.timezone 'Europe/Belgrade', 269, 6, 41, 2 end country 'SJ', 'Svalbard & Jan Mayen' do |c| c.timezone 'Europe/Oslo', 719, 12, 43, 4 end country 'SK', 'Slovakia' do |c| c.timezone 'Europe/Prague', 601, 12, 433, 30 end country 'SL', 'Sierra Leone' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'SM', 'San Marino' do |c| c.timezone 'Europe/Rome', 419, 10, 749, 60 end country 'SN', 'Senegal' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'SO', 'Somalia' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'SR', 'Suriname' do |c| c.timezone 'America/Paramaribo', 35, 6, -331, 6 end country 'SS', 'South Sudan' do |c| c.timezone 'Africa/Khartoum', 78, 5, 488, 15 end country 'ST', 'Sao Tome & Principe' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'SV', 'El Salvador' do |c| c.timezone 'America/El_Salvador', 137, 10, -446, 5 end country 'SX', 'St Maarten (Dutch part)' do |c| c.timezone 'America/Curacao', 731, 60, -69, 1 end country 'SY', 'Syria' do |c| c.timezone 'Asia/Damascus', 67, 2, 363, 10 end country 'SZ', 'Swaziland' do |c| c.timezone 'Africa/Johannesburg', -105, 4, 28, 1 end country 'TC', 'Turks & Caicos Is' do |c| c.timezone 'America/Grand_Turk', 322, 15, -1067, 15 end country 'TD', 'Chad' do |c| c.timezone 'Africa/Ndjamena', 727, 60, 301, 20 end country 'TF', 'French Southern & Antarctic Lands' do |c| c.timezone 'Indian/Kerguelen', -17767, 360, 28087, 400, 'Kerguelen, St Paul I, Amsterdam I' c.timezone 'Indian/Reunion', -313, 15, 832, 15, 'Réunion, Crozet Is, Scattered Is' end country 'TG', 'Togo' do |c| c.timezone 'Africa/Abidjan', 319, 60, -121, 30 end country 'TH', 'Thailand' do |c| c.timezone 'Asia/Bangkok', 55, 4, 6031, 60 end country 'TJ', 'Tajikistan' do |c| c.timezone 'Asia/Dushanbe', 463, 12, 344, 5 end country 'TK', 'Tokelau' do |c| c.timezone 'Pacific/Fakaofo', -281, 30, -5137, 30 end country 'TL', 'East Timor' do |c| c.timezone 'Asia/Dili', -171, 20, 1507, 12 end country 'TM', 'Turkmenistan' do |c| c.timezone 'Asia/Ashgabat', 759, 20, 3503, 60 end country 'TN', 'Tunisia' do |c| c.timezone 'Africa/Tunis', 184, 5, 611, 60 end country 'TO', 'Tonga' do |c| c.timezone 'Pacific/Tongatapu', -127, 6, -1051, 6 end country 'TR', 'Turkey' do |c| c.timezone 'Europe/Istanbul', 2461, 60, 869, 30 end country 'TT', 'Trinidad & Tobago' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'TV', 'Tuvalu' do |c| c.timezone 'Pacific/Funafuti', -511, 60, 10753, 60 end country 'TW', 'Taiwan' do |c| c.timezone 'Asia/Taipei', 501, 20, 243, 2 end country 'TZ', 'Tanzania' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'UA', 'Ukraine' do |c| c.timezone 'Europe/Kiev', 1513, 30, 1831, 60, 'most locations' c.timezone 'Europe/Uzhgorod', 2917, 60, 223, 10, 'Ruthenia' c.timezone 'Europe/Zaporozhye', 287, 6, 211, 6, 'Zaporozh\'ye, E Lugansk / Zaporizhia, E Luhansk' end country 'UG', 'Uganda' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'UM', 'US minor outlying islands' do |c| c.timezone 'Pacific/Wake', 1157, 60, 9997, 60, 'Wake Island' c.timezone 'Pacific/Pago_Pago', -214, 15, -1707, 10, 'Samoa, Midway' c.timezone 'Pacific/Honolulu', 15341, 720, -18943, 120, 'Hawaii time' end country 'US', 'United States' do |c| c.timezone 'America/New_York', 48857, 1200, -266423, 3600, 'Eastern Time' c.timezone 'America/Detroit', 152393, 3600, -19931, 240, 'Eastern Time - Michigan - most locations' c.timezone 'America/Kentucky/Louisville', 9181, 240, -154367, 1800, 'Eastern Time - Kentucky - Louisville area' c.timezone 'America/Kentucky/Monticello', 132587, 3600, -101819, 1200, 'Eastern Time - Kentucky - Wayne County' c.timezone 'America/Indiana/Indianapolis', 23861, 600, -310169, 3600, 'Eastern Time - Indiana - most locations' c.timezone 'America/Indiana/Vincennes', 69619, 1800, -315103, 3600, 'Eastern Time - Indiana - Daviess, Dubois, Knox & Martin Counties' c.timezone 'America/Indiana/Winamac', 29557, 720, -311771, 3600, 'Eastern Time - Indiana - Pulaski County' c.timezone 'America/Indiana/Marengo', 17269, 450, -310841, 3600, 'Eastern Time - Indiana - Crawford County' c.timezone 'America/Indiana/Petersburg', 138571, 3600, -314203, 3600, 'Eastern Time - Indiana - Pike County' c.timezone 'America/Indiana/Vevay', 34873, 900, -153121, 1800, 'Eastern Time - Indiana - Switzerland County' c.timezone 'America/Chicago', 837, 20, -1753, 20, 'Central Time' c.timezone 'America/Indiana/Tell_City', 136631, 3600, -312341, 3600, 'Central Time - Indiana - Perry County' c.timezone 'America/Indiana/Knox', 9911, 240, -693, 8, 'Central Time - Indiana - Starke County' c.timezone 'America/Menominee', 40597, 900, -105137, 1200, 'Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties' c.timezone 'America/North_Dakota/Center', 169619, 3600, -121559, 1200, 'Central Time - North Dakota - Oliver County' c.timezone 'America/North_Dakota/New_Salem', 9369, 200, -121693, 1200, 'Central Time - North Dakota - Morton County (except Mandan area)' c.timezone 'America/North_Dakota/Beulah', 56717, 1200, -916, 9, 'Central Time - North Dakota - Mercer County' c.timezone 'America/Denver', 47687, 1200, -125981, 1200, 'Mountain Time' c.timezone 'America/Boise', 157009, 3600, -46481, 400, 'Mountain Time - south Idaho & east Oregon' c.timezone 'America/Phoenix', 20069, 600, -16811, 150, 'Mountain Standard Time - Arizona (except Navajo)' c.timezone 'America/Los_Angeles', 30647, 900, -212837, 1800, 'Pacific Time' c.timezone 'America/Metlakatla', 198457, 3600, -18947, 144, 'Pacific Standard Time - Annette Island, Alaska' c.timezone 'America/Anchorage', 44077, 720, -539641, 3600, 'Alaska Time' c.timezone 'America/Juneau', 209887, 3600, -483911, 3600, 'Alaska Time - Alaska panhandle' c.timezone 'America/Sitka', 41167, 720, -487087, 3600, 'Alaska Time - southeast Alaska panhandle' c.timezone 'America/Yakutat', 214369, 3600, -251509, 1800, 'Alaska Time - Alaska panhandle neck' c.timezone 'America/Nome', 58051, 900, -595463, 3600, 'Alaska Time - west Alaska' c.timezone 'America/Adak', 1297, 25, -635969, 3600, 'Aleutian Islands' c.timezone 'Pacific/Honolulu', 15341, 720, -18943, 120, 'Hawaii time' end country 'UY', 'Uruguay' do |c| c.timezone 'America/Montevideo', -2093, 60, -3371, 60 end country 'UZ', 'Uzbekistan' do |c| c.timezone 'Asia/Samarkand', 119, 3, 334, 5, 'west Uzbekistan' c.timezone 'Asia/Tashkent', 124, 3, 693, 10, 'east Uzbekistan' end country 'VA', 'Vatican City' do |c| c.timezone 'Europe/Rome', 419, 10, 749, 60 end country 'VC', 'St Vincent' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'VE', 'Venezuela' do |c| c.timezone 'America/Caracas', 21, 2, -1004, 15 end country 'VG', 'Virgin Islands (UK)' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'VI', 'Virgin Islands (US)' do |c| c.timezone 'America/Port_of_Spain', 213, 20, -3691, 60 end country 'VN', 'Vietnam' do |c| c.timezone 'Asia/Bangkok', 55, 4, 6031, 60 end country 'VU', 'Vanuatu' do |c| c.timezone 'Pacific/Efate', -53, 3, 2021, 12 end country 'WF', 'Wallis & Futuna' do |c| c.timezone 'Pacific/Wallis', -133, 10, -1057, 6 end country 'WS', 'Samoa (western)' do |c| c.timezone 'Pacific/Apia', -83, 6, -2576, 15 end country 'YE', 'Yemen' do |c| c.timezone 'Asia/Riyadh', 739, 30, 2803, 60 end country 'YT', 'Mayotte' do |c| c.timezone 'Africa/Nairobi', -77, 60, 2209, 60 end country 'ZA', 'South Africa' do |c| c.timezone 'Africa/Johannesburg', -105, 4, 28, 1 end country 'ZM', 'Zambia' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end country 'ZW', 'Zimbabwe' do |c| c.timezone 'Africa/Maputo', -779, 30, 391, 12, 'Central Africa Time (UTC+2)' end end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/indexes/timezones.rb0000644000004100000410000005152212400401360024472 0ustar www-datawww-data# encoding: UTF-8 # This file contains data derived from the IANA Time Zone Database # (http://www.iana.org/time-zones). module TZInfo module Data module Indexes module Timezones include TimezoneIndexDefinition timezone 'Africa/Abidjan' timezone 'Africa/Accra' timezone 'Africa/Addis_Ababa' timezone 'Africa/Algiers' timezone 'Africa/Asmara' linked_timezone 'Africa/Asmera' linked_timezone 'Africa/Bamako' timezone 'Africa/Bangui' linked_timezone 'Africa/Banjul' timezone 'Africa/Bissau' timezone 'Africa/Blantyre' timezone 'Africa/Brazzaville' timezone 'Africa/Bujumbura' timezone 'Africa/Cairo' timezone 'Africa/Casablanca' timezone 'Africa/Ceuta' linked_timezone 'Africa/Conakry' linked_timezone 'Africa/Dakar' timezone 'Africa/Dar_es_Salaam' timezone 'Africa/Djibouti' timezone 'Africa/Douala' timezone 'Africa/El_Aaiun' linked_timezone 'Africa/Freetown' timezone 'Africa/Gaborone' timezone 'Africa/Harare' timezone 'Africa/Johannesburg' linked_timezone 'Africa/Juba' timezone 'Africa/Kampala' timezone 'Africa/Khartoum' timezone 'Africa/Kigali' timezone 'Africa/Kinshasa' timezone 'Africa/Lagos' timezone 'Africa/Libreville' linked_timezone 'Africa/Lome' timezone 'Africa/Luanda' timezone 'Africa/Lubumbashi' timezone 'Africa/Lusaka' timezone 'Africa/Malabo' timezone 'Africa/Maputo' timezone 'Africa/Maseru' timezone 'Africa/Mbabane' timezone 'Africa/Mogadishu' timezone 'Africa/Monrovia' timezone 'Africa/Nairobi' timezone 'Africa/Ndjamena' timezone 'Africa/Niamey' linked_timezone 'Africa/Nouakchott' linked_timezone 'Africa/Ouagadougou' timezone 'Africa/Porto-Novo' linked_timezone 'Africa/Sao_Tome' linked_timezone 'Africa/Timbuktu' timezone 'Africa/Tripoli' timezone 'Africa/Tunis' timezone 'Africa/Windhoek' timezone 'America/Adak' timezone 'America/Anchorage' linked_timezone 'America/Anguilla' timezone 'America/Antigua' timezone 'America/Araguaina' timezone 'America/Argentina/Buenos_Aires' timezone 'America/Argentina/Catamarca' linked_timezone 'America/Argentina/ComodRivadavia' timezone 'America/Argentina/Cordoba' timezone 'America/Argentina/Jujuy' timezone 'America/Argentina/La_Rioja' timezone 'America/Argentina/Mendoza' timezone 'America/Argentina/Rio_Gallegos' timezone 'America/Argentina/Salta' timezone 'America/Argentina/San_Juan' timezone 'America/Argentina/San_Luis' timezone 'America/Argentina/Tucuman' timezone 'America/Argentina/Ushuaia' linked_timezone 'America/Aruba' timezone 'America/Asuncion' timezone 'America/Atikokan' linked_timezone 'America/Atka' timezone 'America/Bahia' timezone 'America/Bahia_Banderas' timezone 'America/Barbados' timezone 'America/Belem' timezone 'America/Belize' timezone 'America/Blanc-Sablon' timezone 'America/Boa_Vista' timezone 'America/Bogota' timezone 'America/Boise' linked_timezone 'America/Buenos_Aires' timezone 'America/Cambridge_Bay' timezone 'America/Campo_Grande' timezone 'America/Cancun' timezone 'America/Caracas' linked_timezone 'America/Catamarca' timezone 'America/Cayenne' timezone 'America/Cayman' timezone 'America/Chicago' timezone 'America/Chihuahua' linked_timezone 'America/Coral_Harbour' linked_timezone 'America/Cordoba' timezone 'America/Costa_Rica' timezone 'America/Creston' timezone 'America/Cuiaba' timezone 'America/Curacao' timezone 'America/Danmarkshavn' timezone 'America/Dawson' timezone 'America/Dawson_Creek' timezone 'America/Denver' timezone 'America/Detroit' linked_timezone 'America/Dominica' timezone 'America/Edmonton' timezone 'America/Eirunepe' timezone 'America/El_Salvador' linked_timezone 'America/Ensenada' linked_timezone 'America/Fort_Wayne' timezone 'America/Fortaleza' timezone 'America/Glace_Bay' timezone 'America/Godthab' timezone 'America/Goose_Bay' timezone 'America/Grand_Turk' linked_timezone 'America/Grenada' linked_timezone 'America/Guadeloupe' timezone 'America/Guatemala' timezone 'America/Guayaquil' timezone 'America/Guyana' timezone 'America/Halifax' timezone 'America/Havana' timezone 'America/Hermosillo' timezone 'America/Indiana/Indianapolis' timezone 'America/Indiana/Knox' timezone 'America/Indiana/Marengo' timezone 'America/Indiana/Petersburg' timezone 'America/Indiana/Tell_City' timezone 'America/Indiana/Vevay' timezone 'America/Indiana/Vincennes' timezone 'America/Indiana/Winamac' linked_timezone 'America/Indianapolis' timezone 'America/Inuvik' timezone 'America/Iqaluit' timezone 'America/Jamaica' linked_timezone 'America/Jujuy' timezone 'America/Juneau' timezone 'America/Kentucky/Louisville' timezone 'America/Kentucky/Monticello' linked_timezone 'America/Knox_IN' linked_timezone 'America/Kralendijk' timezone 'America/La_Paz' timezone 'America/Lima' timezone 'America/Los_Angeles' linked_timezone 'America/Louisville' linked_timezone 'America/Lower_Princes' timezone 'America/Maceio' timezone 'America/Managua' timezone 'America/Manaus' linked_timezone 'America/Marigot' timezone 'America/Martinique' timezone 'America/Matamoros' timezone 'America/Mazatlan' linked_timezone 'America/Mendoza' timezone 'America/Menominee' timezone 'America/Merida' timezone 'America/Metlakatla' timezone 'America/Mexico_City' timezone 'America/Miquelon' timezone 'America/Moncton' timezone 'America/Monterrey' timezone 'America/Montevideo' timezone 'America/Montreal' linked_timezone 'America/Montserrat' timezone 'America/Nassau' timezone 'America/New_York' timezone 'America/Nipigon' timezone 'America/Nome' timezone 'America/Noronha' timezone 'America/North_Dakota/Beulah' timezone 'America/North_Dakota/Center' timezone 'America/North_Dakota/New_Salem' timezone 'America/Ojinaga' timezone 'America/Panama' timezone 'America/Pangnirtung' timezone 'America/Paramaribo' timezone 'America/Phoenix' timezone 'America/Port-au-Prince' timezone 'America/Port_of_Spain' linked_timezone 'America/Porto_Acre' timezone 'America/Porto_Velho' timezone 'America/Puerto_Rico' timezone 'America/Rainy_River' timezone 'America/Rankin_Inlet' timezone 'America/Recife' timezone 'America/Regina' timezone 'America/Resolute' timezone 'America/Rio_Branco' linked_timezone 'America/Rosario' timezone 'America/Santa_Isabel' timezone 'America/Santarem' timezone 'America/Santiago' timezone 'America/Santo_Domingo' timezone 'America/Sao_Paulo' timezone 'America/Scoresbysund' linked_timezone 'America/Shiprock' timezone 'America/Sitka' linked_timezone 'America/St_Barthelemy' timezone 'America/St_Johns' linked_timezone 'America/St_Kitts' linked_timezone 'America/St_Lucia' linked_timezone 'America/St_Thomas' linked_timezone 'America/St_Vincent' timezone 'America/Swift_Current' timezone 'America/Tegucigalpa' timezone 'America/Thule' timezone 'America/Thunder_Bay' timezone 'America/Tijuana' timezone 'America/Toronto' linked_timezone 'America/Tortola' timezone 'America/Vancouver' linked_timezone 'America/Virgin' timezone 'America/Whitehorse' timezone 'America/Winnipeg' timezone 'America/Yakutat' timezone 'America/Yellowknife' timezone 'Antarctica/Casey' timezone 'Antarctica/Davis' timezone 'Antarctica/DumontDUrville' timezone 'Antarctica/Macquarie' timezone 'Antarctica/Mawson' linked_timezone 'Antarctica/McMurdo' timezone 'Antarctica/Palmer' timezone 'Antarctica/Rothera' linked_timezone 'Antarctica/South_Pole' timezone 'Antarctica/Syowa' timezone 'Antarctica/Troll' timezone 'Antarctica/Vostok' linked_timezone 'Arctic/Longyearbyen' timezone 'Asia/Aden' timezone 'Asia/Almaty' timezone 'Asia/Amman' timezone 'Asia/Anadyr' timezone 'Asia/Aqtau' timezone 'Asia/Aqtobe' timezone 'Asia/Ashgabat' linked_timezone 'Asia/Ashkhabad' timezone 'Asia/Baghdad' timezone 'Asia/Bahrain' timezone 'Asia/Baku' timezone 'Asia/Bangkok' timezone 'Asia/Beirut' timezone 'Asia/Bishkek' timezone 'Asia/Brunei' linked_timezone 'Asia/Calcutta' timezone 'Asia/Chita' timezone 'Asia/Choibalsan' linked_timezone 'Asia/Chongqing' linked_timezone 'Asia/Chungking' timezone 'Asia/Colombo' linked_timezone 'Asia/Dacca' timezone 'Asia/Damascus' timezone 'Asia/Dhaka' timezone 'Asia/Dili' timezone 'Asia/Dubai' timezone 'Asia/Dushanbe' timezone 'Asia/Gaza' linked_timezone 'Asia/Harbin' timezone 'Asia/Hebron' timezone 'Asia/Ho_Chi_Minh' timezone 'Asia/Hong_Kong' timezone 'Asia/Hovd' timezone 'Asia/Irkutsk' linked_timezone 'Asia/Istanbul' timezone 'Asia/Jakarta' timezone 'Asia/Jayapura' timezone 'Asia/Jerusalem' timezone 'Asia/Kabul' timezone 'Asia/Kamchatka' timezone 'Asia/Karachi' linked_timezone 'Asia/Kashgar' timezone 'Asia/Kathmandu' linked_timezone 'Asia/Katmandu' timezone 'Asia/Khandyga' timezone 'Asia/Kolkata' timezone 'Asia/Krasnoyarsk' timezone 'Asia/Kuala_Lumpur' timezone 'Asia/Kuching' timezone 'Asia/Kuwait' linked_timezone 'Asia/Macao' timezone 'Asia/Macau' timezone 'Asia/Magadan' timezone 'Asia/Makassar' timezone 'Asia/Manila' timezone 'Asia/Muscat' timezone 'Asia/Nicosia' timezone 'Asia/Novokuznetsk' timezone 'Asia/Novosibirsk' timezone 'Asia/Omsk' timezone 'Asia/Oral' timezone 'Asia/Phnom_Penh' timezone 'Asia/Pontianak' timezone 'Asia/Pyongyang' timezone 'Asia/Qatar' timezone 'Asia/Qyzylorda' timezone 'Asia/Rangoon' timezone 'Asia/Riyadh' linked_timezone 'Asia/Saigon' timezone 'Asia/Sakhalin' timezone 'Asia/Samarkand' timezone 'Asia/Seoul' timezone 'Asia/Shanghai' timezone 'Asia/Singapore' timezone 'Asia/Srednekolymsk' timezone 'Asia/Taipei' timezone 'Asia/Tashkent' timezone 'Asia/Tbilisi' timezone 'Asia/Tehran' linked_timezone 'Asia/Tel_Aviv' linked_timezone 'Asia/Thimbu' timezone 'Asia/Thimphu' timezone 'Asia/Tokyo' linked_timezone 'Asia/Ujung_Pandang' timezone 'Asia/Ulaanbaatar' linked_timezone 'Asia/Ulan_Bator' timezone 'Asia/Urumqi' timezone 'Asia/Ust-Nera' timezone 'Asia/Vientiane' timezone 'Asia/Vladivostok' timezone 'Asia/Yakutsk' timezone 'Asia/Yekaterinburg' timezone 'Asia/Yerevan' timezone 'Atlantic/Azores' timezone 'Atlantic/Bermuda' timezone 'Atlantic/Canary' timezone 'Atlantic/Cape_Verde' linked_timezone 'Atlantic/Faeroe' timezone 'Atlantic/Faroe' linked_timezone 'Atlantic/Jan_Mayen' timezone 'Atlantic/Madeira' timezone 'Atlantic/Reykjavik' timezone 'Atlantic/South_Georgia' linked_timezone 'Atlantic/St_Helena' timezone 'Atlantic/Stanley' linked_timezone 'Australia/ACT' timezone 'Australia/Adelaide' timezone 'Australia/Brisbane' timezone 'Australia/Broken_Hill' linked_timezone 'Australia/Canberra' timezone 'Australia/Currie' timezone 'Australia/Darwin' timezone 'Australia/Eucla' timezone 'Australia/Hobart' linked_timezone 'Australia/LHI' timezone 'Australia/Lindeman' timezone 'Australia/Lord_Howe' timezone 'Australia/Melbourne' linked_timezone 'Australia/NSW' linked_timezone 'Australia/North' timezone 'Australia/Perth' linked_timezone 'Australia/Queensland' linked_timezone 'Australia/South' timezone 'Australia/Sydney' linked_timezone 'Australia/Tasmania' linked_timezone 'Australia/Victoria' linked_timezone 'Australia/West' linked_timezone 'Australia/Yancowinna' linked_timezone 'Brazil/Acre' linked_timezone 'Brazil/DeNoronha' linked_timezone 'Brazil/East' linked_timezone 'Brazil/West' timezone 'CET' timezone 'CST6CDT' linked_timezone 'Canada/Atlantic' linked_timezone 'Canada/Central' linked_timezone 'Canada/East-Saskatchewan' linked_timezone 'Canada/Eastern' linked_timezone 'Canada/Mountain' linked_timezone 'Canada/Newfoundland' linked_timezone 'Canada/Pacific' linked_timezone 'Canada/Saskatchewan' linked_timezone 'Canada/Yukon' linked_timezone 'Chile/Continental' linked_timezone 'Chile/EasterIsland' linked_timezone 'Cuba' timezone 'EET' timezone 'EST' timezone 'EST5EDT' linked_timezone 'Egypt' linked_timezone 'Eire' timezone 'Etc/GMT' linked_timezone 'Etc/GMT+0' timezone 'Etc/GMT+1' timezone 'Etc/GMT+10' timezone 'Etc/GMT+11' timezone 'Etc/GMT+12' timezone 'Etc/GMT+2' timezone 'Etc/GMT+3' timezone 'Etc/GMT+4' timezone 'Etc/GMT+5' timezone 'Etc/GMT+6' timezone 'Etc/GMT+7' timezone 'Etc/GMT+8' timezone 'Etc/GMT+9' linked_timezone 'Etc/GMT-0' timezone 'Etc/GMT-1' timezone 'Etc/GMT-10' timezone 'Etc/GMT-11' timezone 'Etc/GMT-12' timezone 'Etc/GMT-13' timezone 'Etc/GMT-14' timezone 'Etc/GMT-2' timezone 'Etc/GMT-3' timezone 'Etc/GMT-4' timezone 'Etc/GMT-5' timezone 'Etc/GMT-6' timezone 'Etc/GMT-7' timezone 'Etc/GMT-8' timezone 'Etc/GMT-9' linked_timezone 'Etc/GMT0' linked_timezone 'Etc/Greenwich' timezone 'Etc/UCT' timezone 'Etc/UTC' linked_timezone 'Etc/Universal' linked_timezone 'Etc/Zulu' timezone 'Europe/Amsterdam' timezone 'Europe/Andorra' timezone 'Europe/Athens' linked_timezone 'Europe/Belfast' timezone 'Europe/Belgrade' timezone 'Europe/Berlin' linked_timezone 'Europe/Bratislava' timezone 'Europe/Brussels' timezone 'Europe/Bucharest' timezone 'Europe/Budapest' linked_timezone 'Europe/Busingen' timezone 'Europe/Chisinau' timezone 'Europe/Copenhagen' timezone 'Europe/Dublin' timezone 'Europe/Gibraltar' linked_timezone 'Europe/Guernsey' timezone 'Europe/Helsinki' linked_timezone 'Europe/Isle_of_Man' timezone 'Europe/Istanbul' linked_timezone 'Europe/Jersey' timezone 'Europe/Kaliningrad' timezone 'Europe/Kiev' timezone 'Europe/Lisbon' linked_timezone 'Europe/Ljubljana' timezone 'Europe/London' timezone 'Europe/Luxembourg' timezone 'Europe/Madrid' timezone 'Europe/Malta' linked_timezone 'Europe/Mariehamn' timezone 'Europe/Minsk' timezone 'Europe/Monaco' timezone 'Europe/Moscow' linked_timezone 'Europe/Nicosia' timezone 'Europe/Oslo' timezone 'Europe/Paris' linked_timezone 'Europe/Podgorica' timezone 'Europe/Prague' timezone 'Europe/Riga' timezone 'Europe/Rome' timezone 'Europe/Samara' linked_timezone 'Europe/San_Marino' linked_timezone 'Europe/Sarajevo' timezone 'Europe/Simferopol' linked_timezone 'Europe/Skopje' timezone 'Europe/Sofia' timezone 'Europe/Stockholm' timezone 'Europe/Tallinn' timezone 'Europe/Tirane' linked_timezone 'Europe/Tiraspol' timezone 'Europe/Uzhgorod' linked_timezone 'Europe/Vaduz' linked_timezone 'Europe/Vatican' timezone 'Europe/Vienna' timezone 'Europe/Vilnius' timezone 'Europe/Volgograd' timezone 'Europe/Warsaw' linked_timezone 'Europe/Zagreb' timezone 'Europe/Zaporozhye' timezone 'Europe/Zurich' linked_timezone 'GB' linked_timezone 'GB-Eire' linked_timezone 'GMT' linked_timezone 'GMT+0' linked_timezone 'GMT-0' linked_timezone 'GMT0' linked_timezone 'Greenwich' timezone 'HST' linked_timezone 'Hongkong' linked_timezone 'Iceland' timezone 'Indian/Antananarivo' timezone 'Indian/Chagos' timezone 'Indian/Christmas' timezone 'Indian/Cocos' timezone 'Indian/Comoro' timezone 'Indian/Kerguelen' timezone 'Indian/Mahe' timezone 'Indian/Maldives' timezone 'Indian/Mauritius' timezone 'Indian/Mayotte' timezone 'Indian/Reunion' linked_timezone 'Iran' linked_timezone 'Israel' linked_timezone 'Jamaica' linked_timezone 'Japan' linked_timezone 'Kwajalein' linked_timezone 'Libya' timezone 'MET' timezone 'MST' timezone 'MST7MDT' linked_timezone 'Mexico/BajaNorte' linked_timezone 'Mexico/BajaSur' linked_timezone 'Mexico/General' linked_timezone 'NZ' linked_timezone 'NZ-CHAT' linked_timezone 'Navajo' linked_timezone 'PRC' timezone 'PST8PDT' timezone 'Pacific/Apia' timezone 'Pacific/Auckland' timezone 'Pacific/Chatham' timezone 'Pacific/Chuuk' timezone 'Pacific/Easter' timezone 'Pacific/Efate' timezone 'Pacific/Enderbury' timezone 'Pacific/Fakaofo' timezone 'Pacific/Fiji' timezone 'Pacific/Funafuti' timezone 'Pacific/Galapagos' timezone 'Pacific/Gambier' timezone 'Pacific/Guadalcanal' timezone 'Pacific/Guam' timezone 'Pacific/Honolulu' linked_timezone 'Pacific/Johnston' timezone 'Pacific/Kiritimati' timezone 'Pacific/Kosrae' timezone 'Pacific/Kwajalein' timezone 'Pacific/Majuro' timezone 'Pacific/Marquesas' timezone 'Pacific/Midway' timezone 'Pacific/Nauru' timezone 'Pacific/Niue' timezone 'Pacific/Norfolk' timezone 'Pacific/Noumea' timezone 'Pacific/Pago_Pago' timezone 'Pacific/Palau' timezone 'Pacific/Pitcairn' timezone 'Pacific/Pohnpei' linked_timezone 'Pacific/Ponape' timezone 'Pacific/Port_Moresby' timezone 'Pacific/Rarotonga' timezone 'Pacific/Saipan' linked_timezone 'Pacific/Samoa' timezone 'Pacific/Tahiti' timezone 'Pacific/Tarawa' timezone 'Pacific/Tongatapu' linked_timezone 'Pacific/Truk' timezone 'Pacific/Wake' timezone 'Pacific/Wallis' linked_timezone 'Pacific/Yap' linked_timezone 'Poland' linked_timezone 'Portugal' linked_timezone 'ROC' linked_timezone 'ROK' linked_timezone 'Singapore' linked_timezone 'Turkey' linked_timezone 'UCT' linked_timezone 'US/Alaska' linked_timezone 'US/Aleutian' linked_timezone 'US/Arizona' linked_timezone 'US/Central' linked_timezone 'US/East-Indiana' linked_timezone 'US/Eastern' linked_timezone 'US/Hawaii' linked_timezone 'US/Indiana-Starke' linked_timezone 'US/Michigan' linked_timezone 'US/Mountain' linked_timezone 'US/Pacific' linked_timezone 'US/Pacific-New' linked_timezone 'US/Samoa' linked_timezone 'UTC' linked_timezone 'Universal' linked_timezone 'W-SU' timezone 'WET' linked_timezone 'Zulu' end end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data/version.rb0000644000004100000410000000062012400401360022474 0ustar www-datawww-datamodule TZInfo module Data # TZInfo::Data version information. module Version # The format of the Ruby modules. The only format currently supported by # TZInfo is version 1. FORMAT = 1 # The version of the {IANA Time Zone Database}[http://www.iana.org/time-zones] # used to generate this version of TZInfo::Data. TZDATA = '2014f' end end end tzinfo-1.2.2/test/tzinfo-data/tzinfo/data.rb0000644000004100000410000000021312400401360021005 0ustar www-datawww-data# Top level module for TZInfo. module TZInfo # Top level module for TZInfo::Data. module Data end end require 'tzinfo/data/version' tzinfo-1.2.2/test/tc_timezone_proxy.rb0000644000004100000410000001275312400401360020140 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneProxy < Minitest::Test def test_not_exist proxy = TimezoneProxy.new('Nothing/Special') assert_equal('Nothing/Special', proxy.identifier) assert_raises(InvalidTimezoneIdentifier) { proxy.now } assert_raises(InvalidTimezoneIdentifier) { proxy.current_period } assert_raises(InvalidTimezoneIdentifier) { proxy.current_period_and_time } assert_raises(InvalidTimezoneIdentifier) { proxy.current_time_and_period } assert_raises(InvalidTimezoneIdentifier) { proxy.utc_to_local(DateTime.new(2006,1,1,0,0,0)) } assert_raises(InvalidTimezoneIdentifier) { proxy.local_to_utc(DateTime.new(2006,1,1,0,0,0)) } assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_utc(DateTime.new(2006,1,1,0,0,0)) } assert_raises(InvalidTimezoneIdentifier) { proxy.period_for_local(DateTime.new(2006,1,1,0,0,0)) } assert_raises(InvalidTimezoneIdentifier) { proxy.canonical_identifier } assert_raises(InvalidTimezoneIdentifier) { proxy.canonical_zone } end def test_valid proxy = TimezoneProxy.new('Europe/London') assert_equal('Europe/London', proxy.identifier) assert_nothing_raised { proxy.now } assert_nothing_raised { proxy.current_period } assert_nothing_raised { proxy.current_period_and_time } assert_nothing_raised { proxy.current_time_and_period } real = Timezone.get('Europe/London') assert_equal(real.utc_to_local(DateTime.new(2005,8,1,0,0,0)), proxy.utc_to_local(DateTime.new(2005,8,1,0,0,0))) assert_equal(real.local_to_utc(DateTime.new(2005,8,1,0,0,0)), proxy.local_to_utc(DateTime.new(2005,8,1,0,0,0))) assert_equal(real.period_for_utc(DateTime.new(2005,8,1,0,0,0)), proxy.period_for_utc(DateTime.new(2005,8,1,0,0,0))) assert_equal(real.period_for_local(DateTime.new(2005,8,1,0,0,0)), proxy.period_for_local(DateTime.new(2005,8,1,0,0,0))) assert_equal(real.identifier, proxy.identifier) assert_equal(real.name, proxy.name) assert_equal(real.to_s, proxy.to_s) assert_equal(real.friendly_identifier(true), proxy.friendly_identifier(true)) assert_equal(real.friendly_identifier(false), proxy.friendly_identifier(false)) assert_equal(real.friendly_identifier, proxy.friendly_identifier) assert_equal(real.canonical_identifier, proxy.canonical_identifier) assert_same(real.canonical_zone, proxy.canonical_zone) assert_equal('Europe/London', proxy.identifier) assert(real == proxy) assert(proxy == real) assert_equal(0, real <=> proxy) assert_equal(0, proxy <=> real) end def test_canonical_linked # Test that the implementation of canonical_zone and canonical_identifier # are actually calling the real timezone and not just returning it and # its identifier. real = Timezone.get('UTC') proxy = TimezoneProxy.new('UTC') # ZoneinfoDataSource doesn't return LinkedTimezoneInfo instances for any # timezone. if real.kind_of?(LinkedTimezone) assert_equal('Etc/UTC', proxy.canonical_identifier) assert_same(Timezone.get('Etc/UTC'), proxy.canonical_zone) else if DataSource.get.kind_of?(RubyDataSource) # Not got a LinkedTimezone despite using a DataSource that supports it. # Raise an exception as this shouldn't happen. raise 'Non-LinkedTimezone instance returned for UTC using RubyDataSource' end assert_equal('UTC', proxy.canonical_identifier) assert_same(Timezone.get('UTC'), proxy.canonical_zone) end end def test_equals assert_equal(true, TimezoneProxy.new('Europe/London') == TimezoneProxy.new('Europe/London')) assert_equal(false, TimezoneProxy.new('Europe/London') == TimezoneProxy.new('Europe/Paris')) assert(!(TimezoneProxy.new('Europe/London') == Object.new)) end def test_compare assert_equal(0, TimezoneProxy.new('Europe/London') <=> TimezoneProxy.new('Europe/London')) assert_equal(0, Timezone.get('Europe/London') <=> TimezoneProxy.new('Europe/London')) assert_equal(0, TimezoneProxy.new('Europe/London') <=> Timezone.get('Europe/London')) assert_equal(-1, TimezoneProxy.new('Europe/London') <=> TimezoneProxy.new('Europe/Paris')) assert_equal(-1, Timezone.get('Europe/London') <=> TimezoneProxy.new('Europe/Paris')) assert_equal(-1, TimezoneProxy.new('Europe/London') <=> Timezone.get('Europe/Paris')) assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> TimezoneProxy.new('Europe/London')) assert_equal(1, Timezone.get('Europe/Paris') <=> TimezoneProxy.new('Europe/London')) assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> Timezone.get('Europe/London')) assert_equal(-1, TimezoneProxy.new('America/New_York') <=> TimezoneProxy.new('Europe/Paris')) assert_equal(-1, Timezone.get('America/New_York') <=> TimezoneProxy.new('Europe/Paris')) assert_equal(-1, TimezoneProxy.new('America/New_York') <=> Timezone.get('Europe/Paris')) assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> TimezoneProxy.new('America/New_York')) assert_equal(1, Timezone.get('Europe/Paris') <=> TimezoneProxy.new('America/New_York')) assert_equal(1, TimezoneProxy.new('Europe/Paris') <=> Timezone.get('America/New_York')) end def test_kind assert_kind_of(Timezone, TimezoneProxy.new('America/New_York')) end def test_marshal tp = TimezoneProxy.new('Europe/London') tp2 = Marshal.load(Marshal.dump(tp)) assert_kind_of(TimezoneProxy, tp2) assert_equal('Europe/London', tp2.identifier) end end tzinfo-1.2.2/test/ts_all_ruby.rb0000644000004100000410000000026612400401360016672 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils.rb') TZInfo::DataSource.set(:ruby) require File.join(File.expand_path(File.dirname(__FILE__)), 'ts_all.rb') tzinfo-1.2.2/test/tc_info_timezone.rb0000644000004100000410000000133112400401360017700 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCInfoTimezone < Minitest::Test class TestInfoTimezone < InfoTimezone attr_reader :setup_info protected def setup(info) super(info) @setup_info = info end end def test_identifier tz = InfoTimezone.new(TimezoneInfo.new('Test/Identifier')) assert_equal('Test/Identifier', tz.identifier) end def test_info i = TimezoneInfo.new('Test/Identifier') tz = InfoTimezone.new(i) assert_same(i, tz.send(:info)) end def test_setup i = TimezoneInfo.new('Test/Identifier') tz = TestInfoTimezone.new(i) assert_same(i, tz.setup_info) end end tzinfo-1.2.2/test/test_utils.rb0000644000004100000410000000760012400401360016551 0ustar www-datawww-dataTESTS_DIR = File.expand_path(File.dirname(__FILE__)).untaint TZINFO_LIB_DIR = File.expand_path(File.join(TESTS_DIR, '..', 'lib')) TZINFO_TEST_DATA_DIR = File.join(TESTS_DIR, 'tzinfo-data') TZINFO_TEST_ZONEINFO_DIR = File.join(TESTS_DIR, 'zoneinfo') $:.unshift(TZINFO_LIB_DIR) unless $:.include?(TZINFO_LIB_DIR) # tzinfo-data contains a cut down copy of tzinfo-data for use in the tests. # Add it to the load path. $:.unshift(TZINFO_TEST_DATA_DIR) unless $:.include?(TZINFO_TEST_DATA_DIR) require 'minitest/autorun' require 'tzinfo' require 'fileutils' require 'rbconfig' module TestUtils ZONEINFO_SYMLINKS = [ ['localtime', 'America/New_York'], ['UTC', 'Etc/UTC']] def self.prepare_test_zoneinfo_dir ZONEINFO_SYMLINKS.each do |file, target| path = File.join(TZINFO_TEST_ZONEINFO_DIR, file) File.delete(path) if File.exist?(path) begin FileUtils.ln_s(target, path) rescue NotImplementedError target_path = File.join(TZINFO_TEST_ZONEINFO_DIR, target) FileUtils.cp(target_path, path) end end end end TestUtils.prepare_test_zoneinfo_dir module Kernel # Suppresses any warnings raised in a specified block. def without_warnings old_verbose = $VERBOSE begin $VERBOSE = nil yield ensure $-v = old_verbose end end def safe_test(options = {}) # JRuby and Rubinus don't support SAFE levels. available = !(defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE)) if available || options[:unavailable] != :skip thread = Thread.new do $SAFE = options[:level] || 1 if available yield end thread.join end end def assert_array_same_items(expected, actual, msg = nil) full_message = message(msg, '') { diff(expected, actual) } condition = (expected.size == actual.size) && (expected - actual == []) assert(condition, full_message) end def assert_sub_process_returns(expected_lines, code, extra_load_path = [], required = ['tzinfo']) ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']) load_path = [TZINFO_LIB_DIR] + extra_load_path # If RubyGems is loaded in the current process, then require it in the # sub-process, as it may be needed in order to require dependencies. if defined?(Gem) && Gem.instance_of?(Module) required = ['rubygems'] + required end if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx' # Stop Rubinus from operating as irb. args = ' -' else args = '' end IO.popen("\"#{ruby}\"#{args}", 'r+') do |process| load_path.each do |p| process.puts("$:.unshift('#{p.gsub("'", "\\\\'")}')") end required.each do |r| process.puts("require '#{r.gsub("'", "\\\\'")}'") end process.puts(code) process.flush process.close_write actual_lines = process.readlines actual_lines = actual_lines.collect {|l| l.chomp} assert_equal(expected_lines, actual_lines) end end def assert_nothing_raised(msg = nil) begin yield rescue => e full_message = message(msg) { exception_details(e, 'Exception raised: ') } assert(false, full_message) end end end # JRuby 1.7.5 to 1.7.9 consider DateTime instances that differ by less than # 1 millisecond to be equivalent (https://github.com/jruby/jruby/issues/1311). # # A few test cases compare at a resolution of 1 microsecond, so this causes # failures on JRuby 1.7.5 to 1.7.9. # # Determine what the platform supports and adjust the tests accordingly. DATETIME_RESOLUTION = (0..5).collect {|i| 10**i}.find {|i| (DateTime.new(2013,1,1,0,0,0) <=> DateTime.new(2013,1,1,0,0,Rational(i,1000000))) < 0} raise 'Unable to compare DateTimes at a resolution less than one second on this platform' unless DATETIME_RESOLUTION tzinfo-1.2.2/test/tc_timezone_new_york.rb0000644000004100000410000002403012400401360020603 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneNewYork < Minitest::Test def test_2004 #America/New_York Sun Apr 4 06:59:59 2004 UTC = Sun Apr 4 01:59:59 2004 EST isdst=0 gmtoff=-18000 #America/New_York Sun Apr 4 07:00:00 2004 UTC = Sun Apr 4 03:00:00 2004 EDT isdst=1 gmtoff=-14400 #America/New_York Sun Oct 31 05:59:59 2004 UTC = Sun Oct 31 01:59:59 2004 EDT isdst=1 gmtoff=-14400 #America/New_York Sun Oct 31 06:00:00 2004 UTC = Sun Oct 31 01:00:00 2004 EST isdst=0 gmtoff=-18000 tz = Timezone.get('America/New_York') assert_equal(DateTime.new(2004,4,4,1,59,59), tz.utc_to_local(DateTime.new(2004,4,4,6,59,59))) assert_equal(DateTime.new(2004,4,4,3,0,0), tz.utc_to_local(DateTime.new(2004,4,4,7,0,0))) assert_equal(DateTime.new(2004,10,31,1,59,59), tz.utc_to_local(DateTime.new(2004,10,31,5,59,59))) assert_equal(DateTime.new(2004,10,31,1,0,0), tz.utc_to_local(DateTime.new(2004,10,31,6,0,0))) assert_equal(DateTime.new(2004,4,4,6,59,59), tz.local_to_utc(DateTime.new(2004,4,4,1,59,59))) assert_equal(DateTime.new(2004,4,4,7,0,0), tz.local_to_utc(DateTime.new(2004,4,4,3,0,0))) assert_equal(DateTime.new(2004,10,31,5,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), true)) assert_equal(DateTime.new(2004,10,31,6,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), false)) assert_equal(DateTime.new(2004,10,31,5,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true)) assert_equal(DateTime.new(2004,10,31,6,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false)) assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,4,4,2,0,0)) } assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) } assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).zone_identifier) assert_equal(:EDT, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).zone_identifier) assert_equal(:EDT, tz.period_for_utc(DateTime.new(2004,10,31,5,59,59)).zone_identifier) assert_equal(:EST, tz.period_for_utc(DateTime.new(2004,10,31,6,0,0)).zone_identifier) assert_equal(:EST, tz.period_for_local(DateTime.new(2004,4,4,1,59,59)).zone_identifier) assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,4,4,3,0,0)).zone_identifier) assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).zone_identifier) assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).zone_identifier) assert_equal(:EDT, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).zone_identifier) assert_equal(:EST, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).zone_identifier) assert_equal(-18000, tz.period_for_utc(DateTime.new(2004,4,4,6,59,59)).utc_total_offset) assert_equal(-14400, tz.period_for_utc(DateTime.new(2004,4,4,7,0,0)).utc_total_offset) assert_equal(-14400, tz.period_for_utc(DateTime.new(2004,10,31,5,59,59)).utc_total_offset) assert_equal(-18000, tz.period_for_utc(DateTime.new(2004,10,31,6,0,0)).utc_total_offset) assert_equal(-18000, tz.period_for_local(DateTime.new(2004,4,4,1,59,59)).utc_total_offset) assert_equal(-14400, tz.period_for_local(DateTime.new(2004,4,4,3,0,0)).utc_total_offset) assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).utc_total_offset) assert_equal(-18000, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).utc_total_offset) assert_equal(-14400, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).utc_total_offset) assert_equal(-18000, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).utc_total_offset) transitions = tz.transitions_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0)) assert_equal(2, transitions.length) assert_equal(TimeOrDateTime.new(DateTime.new(2004,4,4,7,0,0)), transitions[0].at) assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[0].previous_offset) assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[0].offset) assert_equal(TimeOrDateTime.new(DateTime.new(2004,10,31,6,0,0)), transitions[1].at) assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[1].previous_offset) assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[1].offset) offsets = tz.offsets_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0)) assert_array_same_items([TimezoneOffset.new(-18000, 0, :EST), TimezoneOffset.new(-18000, 3600, :EDT)], offsets) end def test_1957 # This test cannot be run when using ZoneinfoDataSource on platforms # that don't support Times before the epoch (i.e. Ruby < 1.9 on Windows) # because it relates to the year 1957. if !DataSource.get.kind_of?(ZoneinfoDataSource) || RubyCoreSupport.time_supports_negative #America/New_York Sun Apr 28 06:59:59 1957 UTC = Sun Apr 28 01:59:59 1957 EST isdst=0 gmtoff=-18000 #America/New_York Sun Apr 28 07:00:00 1957 UTC = Sun Apr 28 03:00:00 1957 EDT isdst=1 gmtoff=-14400 #America/New_York Sun Oct 27 05:59:59 1957 UTC = Sun Oct 27 01:59:59 1957 EDT isdst=1 gmtoff=-14400 #America/New_York Sun Oct 27 06:00:00 1957 UTC = Sun Oct 27 01:00:00 1957 EST isdst=0 gmtoff=-18000 tz = Timezone.get('America/New_York') assert_equal(DateTime.new(1957,4,28,1,59,59), tz.utc_to_local(DateTime.new(1957,4,28,6,59,59))) assert_equal(DateTime.new(1957,4,28,3,0,0), tz.utc_to_local(DateTime.new(1957,4,28,7,0,0))) assert_equal(DateTime.new(1957,10,27,1,59,59), tz.utc_to_local(DateTime.new(1957,10,27,5,59,59))) assert_equal(DateTime.new(1957,10,27,1,0,0), tz.utc_to_local(DateTime.new(1957,10,27,6,0,0))) assert_equal(DateTime.new(1957,4,28,6,59,59), tz.local_to_utc(DateTime.new(1957,4,28,1,59,59))) assert_equal(DateTime.new(1957,4,28,7,0,0), tz.local_to_utc(DateTime.new(1957,4,28,3,0,0))) assert_equal(DateTime.new(1957,10,27,5,59,59), tz.local_to_utc(DateTime.new(1957,10,27,1,59,59), true)) assert_equal(DateTime.new(1957,10,27,6,59,59), tz.local_to_utc(DateTime.new(1957,10,27,1,59,59), false)) assert_equal(DateTime.new(1957,10,27,5,0,0), tz.local_to_utc(DateTime.new(1957,10,27,1,0,0), true)) assert_equal(DateTime.new(1957,10,27,6,0,0), tz.local_to_utc(DateTime.new(1957,10,27,1,0,0), false)) assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1957,4,28,2,0,0)) } assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1957,10,27,1,0,0)) } assert_equal(:EST, tz.period_for_utc(DateTime.new(1957,4,28,6,59,59)).zone_identifier) assert_equal(:EDT, tz.period_for_utc(DateTime.new(1957,4,28,7,0,0)).zone_identifier) assert_equal(:EDT, tz.period_for_utc(DateTime.new(1957,10,27,5,59,59)).zone_identifier) assert_equal(:EST, tz.period_for_utc(DateTime.new(1957,10,27,6,0,0)).zone_identifier) assert_equal(:EST, tz.period_for_local(DateTime.new(1957,4,28,1,59,59)).zone_identifier) assert_equal(:EDT, tz.period_for_local(DateTime.new(1957,4,28,3,0,0)).zone_identifier) assert_equal(:EDT, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), true).zone_identifier) assert_equal(:EST, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), false).zone_identifier) assert_equal(:EDT, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), true).zone_identifier) assert_equal(:EST, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), false).zone_identifier) assert_equal(-18000, tz.period_for_utc(DateTime.new(1957,4,28,6,59,59)).utc_total_offset) assert_equal(-14400, tz.period_for_utc(DateTime.new(1957,4,28,7,0,0)).utc_total_offset) assert_equal(-14400, tz.period_for_utc(DateTime.new(1957,10,27,5,59,59)).utc_total_offset) assert_equal(-18000, tz.period_for_utc(DateTime.new(1957,10,27,6,0,0)).utc_total_offset) assert_equal(-18000, tz.period_for_local(DateTime.new(1957,4,28,1,59,59)).utc_total_offset) assert_equal(-14400, tz.period_for_local(DateTime.new(1957,4,28,3,0,0)).utc_total_offset) assert_equal(-14400, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), true).utc_total_offset) assert_equal(-18000, tz.period_for_local(DateTime.new(1957,10,27,1,59,59), false).utc_total_offset) assert_equal(-14400, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), true).utc_total_offset) assert_equal(-18000, tz.period_for_local(DateTime.new(1957,10,27,1,0,0), false).utc_total_offset) transitions = tz.transitions_up_to(DateTime.new(1958,1,1,0,0,0), DateTime.new(1957,1,1,0,0,0)) assert_equal(2, transitions.length) assert_equal(TimeOrDateTime.new(DateTime.new(1957,4,28,7,0,0)), transitions[0].at) assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[0].previous_offset) assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[0].offset) assert_equal(TimeOrDateTime.new(DateTime.new(1957,10,27,6,0,0)), transitions[1].at) assert_equal(TimezoneOffset.new(-18000, 3600, :EDT), transitions[1].previous_offset) assert_equal(TimezoneOffset.new(-18000, 0, :EST), transitions[1].offset) offsets = tz.offsets_up_to(DateTime.new(1958,1,1,0,0,0), DateTime.new(1957,1,1,0,0,0)) assert_array_same_items([TimezoneOffset.new(-18000, 0, :EST), TimezoneOffset.new(-18000, 3600, :EDT)], offsets) end end def test_time_boundary #America/New_York Sun Oct 26 06:00:00 1969 UTC = Sun Oct 26 01:00:00 1969 EST isdst=0 gmtoff=-18000 #America/New_York Sun Apr 26 06:59:59 1970 UTC = Sun Apr 26 01:59:59 1970 EST isdst=0 gmtoff=-18000 tz = Timezone.get('America/New_York') assert_equal(DateTime.new(1970,1,1,0,0,0), tz.utc_to_local(DateTime.new(1970,1,1,5,0,0))) assert_equal(DateTime.new(1970,1,1,5,0,0), tz.local_to_utc(DateTime.new(1970,1,1,0,0,0))) assert_equal(Time.utc(1970,1,1,0,0,0), tz.utc_to_local(Time.utc(1970,1,1,5,0,0))) assert_equal(Time.utc(1970,1,1,5,0,0), tz.local_to_utc(Time.utc(1970,1,1,0,0,0))) assert_equal(0, tz.utc_to_local(18000)) assert_equal(18000, tz.local_to_utc(0)) end end tzinfo-1.2.2/test/tc_timezone_london.rb0000644000004100000410000002354012400401360020244 0ustar www-datawww-datarequire File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils') include TZInfo class TCTimezoneLondon < Minitest::Test def test_2004 #Europe/London Sun Mar 28 00:59:59 2004 UTC = Sun Mar 28 00:59:59 2004 GMT isdst=0 gmtoff=0 #Europe/London Sun Mar 28 01:00:00 2004 UTC = Sun Mar 28 02:00:00 2004 BST isdst=1 gmtoff=3600 #Europe/London Sun Oct 31 00:59:59 2004 UTC = Sun Oct 31 01:59:59 2004 BST isdst=1 gmtoff=3600 #Europe/London Sun Oct 31 01:00:00 2004 UTC = Sun Oct 31 01:00:00 2004 GMT isdst=0 gmtoff=0 tz = Timezone.get('Europe/London') assert_equal(DateTime.new(2004,3,28,0,59,59), tz.utc_to_local(DateTime.new(2004,3,28,0,59,59))) assert_equal(DateTime.new(2004,3,28,2,0,0), tz.utc_to_local(DateTime.new(2004,3,28,1,0,0))) assert_equal(DateTime.new(2004,10,31,1,59,59), tz.utc_to_local(DateTime.new(2004,10,31,0,59,59))) assert_equal(DateTime.new(2004,10,31,1,0,0), tz.utc_to_local(DateTime.new(2004,10,31,1,0,0))) assert_equal(DateTime.new(2004,3,28,0,59,59), tz.local_to_utc(DateTime.new(2004,3,28,0,59,59))) assert_equal(DateTime.new(2004,3,28,1,0,0), tz.local_to_utc(DateTime.new(2004,3,28,2,0,0))) assert_equal(DateTime.new(2004,10,31,0,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), true)) assert_equal(DateTime.new(2004,10,31,1,59,59), tz.local_to_utc(DateTime.new(2004,10,31,1,59,59), false)) assert_equal(DateTime.new(2004,10,31,0,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), true)) assert_equal(DateTime.new(2004,10,31,1,0,0), tz.local_to_utc(DateTime.new(2004,10,31,1,0,0), false)) assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(2004,3,28,1,0,0)) } assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(2004,10,31,1,0,0)) } assert_equal(:GMT, tz.period_for_utc(DateTime.new(2004,3,28,0,59,59)).zone_identifier) assert_equal(:BST, tz.period_for_utc(DateTime.new(2004,3,28,1,0,0)).zone_identifier) assert_equal(:BST, tz.period_for_utc(DateTime.new(2004,10,31,0,59,59)).zone_identifier) assert_equal(:GMT, tz.period_for_utc(DateTime.new(2004,10,31,1,0,0)).zone_identifier) assert_equal(:GMT, tz.period_for_local(DateTime.new(2004,3,28,0,59,59)).zone_identifier) assert_equal(:BST, tz.period_for_local(DateTime.new(2004,3,28,2,0,0)).zone_identifier) assert_equal(:BST, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).zone_identifier) assert_equal(:GMT, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).zone_identifier) assert_equal(:BST, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).zone_identifier) assert_equal(:GMT, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).zone_identifier) assert_equal(0, tz.period_for_utc(DateTime.new(2004,3,28,0,59,59)).utc_total_offset) assert_equal(3600, tz.period_for_utc(DateTime.new(2004,3,28,1,0,0)).utc_total_offset) assert_equal(3600, tz.period_for_utc(DateTime.new(2004,10,31,0,59,59)).utc_total_offset) assert_equal(0, tz.period_for_utc(DateTime.new(2004,10,31,1,0,0)).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(2004,3,28,0,59,59)).utc_total_offset) assert_equal(3600, tz.period_for_local(DateTime.new(2004,3,28,2,0,0)).utc_total_offset) assert_equal(3600, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), true).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(2004,10,31,1,59,59), false).utc_total_offset) assert_equal(3600, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), true).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(2004,10,31,1,0,0), false).utc_total_offset) transitions = tz.transitions_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0)) assert_equal(2, transitions.length) assert_equal(TimeOrDateTime.new(DateTime.new(2004,3,28,1,0,0)), transitions[0].at) assert_equal(TimezoneOffset.new(0, 0, :GMT), transitions[0].previous_offset) assert_equal(TimezoneOffset.new(0, 3600, :BST), transitions[0].offset) assert_equal(TimeOrDateTime.new(DateTime.new(2004,10,31,1,0,0)), transitions[1].at) assert_equal(TimezoneOffset.new(0, 3600, :BST), transitions[1].previous_offset) assert_equal(TimezoneOffset.new(0, 0, :GMT), transitions[1].offset) offsets = tz.offsets_up_to(DateTime.new(2005,1,1,0,0,0), DateTime.new(2004,1,1,0,0,0)) assert_array_same_items([TimezoneOffset.new(0, 0, :GMT), TimezoneOffset.new(0, 3600, :BST)], offsets) end def test_1961 # This test cannot be run when using ZoneinfoDataSource on platforms # that don't support Times before the epoch (i.e. Ruby < 1.9 on Windows) # because it relates to the year 1961. if !DataSource.get.kind_of?(ZoneinfoDataSource) || RubyCoreSupport.time_supports_negative #Europe/London Sun Mar 26 01:59:59 1961 UTC = Sun Mar 26 01:59:59 1961 GMT isdst=0 gmtoff=0 #Europe/London Sun Mar 26 02:00:00 1961 UTC = Sun Mar 26 03:00:00 1961 BST isdst=1 gmtoff=3600 #Europe/London Sun Oct 29 01:59:59 1961 UTC = Sun Oct 29 02:59:59 1961 BST isdst=1 gmtoff=3600 #Europe/London Sun Oct 29 02:00:00 1961 UTC = Sun Oct 29 02:00:00 1961 GMT isdst=0 gmtoff=0 tz = Timezone.get('Europe/London') assert_equal(DateTime.new(1961,3,26,1,59,59), tz.utc_to_local(DateTime.new(1961,3,26,1,59,59))) assert_equal(DateTime.new(1961,3,26,3,0,0), tz.utc_to_local(DateTime.new(1961,3,26,2,0,0))) assert_equal(DateTime.new(1961,10,29,2,59,59), tz.utc_to_local(DateTime.new(1961,10,29,1,59,59))) assert_equal(DateTime.new(1961,10,29,2,0,0), tz.utc_to_local(DateTime.new(1961,10,29,2,0,0))) assert_equal(DateTime.new(1961,3,26,1,59,59), tz.local_to_utc(DateTime.new(1961,3,26,1,59,59))) assert_equal(DateTime.new(1961,3,26,2,0,0), tz.local_to_utc(DateTime.new(1961,3,26,3,0,0))) assert_equal(DateTime.new(1961,10,29,1,59,59), tz.local_to_utc(DateTime.new(1961,10,29,2,59,59), true)) assert_equal(DateTime.new(1961,10,29,2,59,59), tz.local_to_utc(DateTime.new(1961,10,29,2,59,59), false)) assert_equal(DateTime.new(1961,10,29,1,0,0), tz.local_to_utc(DateTime.new(1961,10,29,2,0,0), true)) assert_equal(DateTime.new(1961,10,29,2,0,0), tz.local_to_utc(DateTime.new(1961,10,29,2,0,0), false)) assert_raises(PeriodNotFound) { tz.local_to_utc(DateTime.new(1961,3,26,2,0,0)) } assert_raises(AmbiguousTime) { tz.local_to_utc(DateTime.new(1961,10,29,2,0,0)) } assert_equal(:GMT, tz.period_for_utc(DateTime.new(1961,3,26,1,59,59)).zone_identifier) assert_equal(:BST, tz.period_for_utc(DateTime.new(1961,3,26,2,0,0)).zone_identifier) assert_equal(:BST, tz.period_for_utc(DateTime.new(1961,10,29,1,59,59)).zone_identifier) assert_equal(:GMT, tz.period_for_utc(DateTime.new(1961,10,29,2,0,0)).zone_identifier) assert_equal(:GMT, tz.period_for_local(DateTime.new(1961,3,26,1,59,59)).zone_identifier) assert_equal(:BST, tz.period_for_local(DateTime.new(1961,3,26,3,0,0)).zone_identifier) assert_equal(:BST, tz.period_for_local(DateTime.new(1961,10,29,2,59,59), true).zone_identifier) assert_equal(:GMT, tz.period_for_local(DateTime.new(1961,10,29,2,59,59), false).zone_identifier) assert_equal(:BST, tz.period_for_local(DateTime.new(1961,10,29,2,0,0), true).zone_identifier) assert_equal(:GMT, tz.period_for_local(DateTime.new(1961,10,29,2,0,0), false).zone_identifier) assert_equal(0, tz.period_for_utc(DateTime.new(1961,3,26,1,59,59)).utc_total_offset) assert_equal(3600, tz.period_for_utc(DateTime.new(1961,3,26,2,0,0)).utc_total_offset) assert_equal(3600, tz.period_for_utc(DateTime.new(1961,10,29,1,59,59)).utc_total_offset) assert_equal(0, tz.period_for_utc(DateTime.new(1961,10,29,2,0,0)).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(1961,3,26,1,59,59)).utc_total_offset) assert_equal(3600, tz.period_for_local(DateTime.new(1961,3,26,3,0,0)).utc_total_offset) assert_equal(3600, tz.period_for_local(DateTime.new(1961,10,29,2,59,59), true).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(1961,10,29,2,59,59), false).utc_total_offset) assert_equal(3600, tz.period_for_local(DateTime.new(1961,10,29,2,0,0), true).utc_total_offset) assert_equal(0, tz.period_for_local(DateTime.new(1961,10,29,2,0,0), false).utc_total_offset) transitions = tz.transitions_up_to(DateTime.new(1962,1,1,0,0,0), DateTime.new(1961,1,1,0,0,0)) assert_equal(2, transitions.length) assert_equal(TimeOrDateTime.new(DateTime.new(1961,3,26,2,0,0)), transitions[0].at) assert_equal(TimezoneOffset.new(0, 0, :GMT), transitions[0].previous_offset) assert_equal(TimezoneOffset.new(0, 3600, :BST), transitions[0].offset) assert_equal(TimeOrDateTime.new(DateTime.new(1961,10,29,2,0,0)), transitions[1].at) assert_equal(TimezoneOffset.new(0, 3600, :BST), transitions[1].previous_offset) assert_equal(TimezoneOffset.new(0, 0, :GMT), transitions[1].offset) offsets = tz.offsets_up_to(DateTime.new(1962,1,1,0,0,0), DateTime.new(1961,1,1,0,0,0)) assert_array_same_items([TimezoneOffset.new(0, 0, :GMT), TimezoneOffset.new(0, 3600, :BST)], offsets) end end def test_time_boundary #Europe/London Sat Oct 26 23:00:00 1968 UTC = Sun Oct 27 00:00:00 1968 GMT isdst=0 gmtoff=3600 #Europe/London Sun Oct 31 01:59:59 1971 UTC = Sun Oct 31 02:59:59 1971 GMT isdst=0 gmtoff=3600 tz = Timezone.get('Europe/London') assert_equal(DateTime.new(1970,1,1,1,0,0), tz.utc_to_local(DateTime.new(1970,1,1,0,0,0))) assert_equal(DateTime.new(1970,1,1,0,0,0), tz.local_to_utc(DateTime.new(1970,1,1,1,0,0))) assert_equal(Time.utc(1970,1,1,1,0,0), tz.utc_to_local(Time.utc(1970,1,1,0,0,0))) assert_equal(Time.utc(1970,1,1,0,0,0), tz.local_to_utc(Time.utc(1970,1,1,1,0,0))) assert_equal(3600, tz.utc_to_local(0)) assert_equal(0, tz.local_to_utc(3600)) end end tzinfo-1.2.2/.yardopts0000644000004100000410000000007012400401360014706 0ustar www-datawww-data--no-private lib/**/*.rb - CHANGES.md LICENSE README.md tzinfo-1.2.2/checksums.yaml.gz.sig0000444000004100000410000000040012400401360017104 0ustar www-datawww-data(G8z)g='gK&kq%6C ?l _.>hd9]{q,AwuOҰS죲_R; ^&}8;]tv22@(ʤ&D=` XOi~i:2M:},'FӬ,P2t)~^+9…:&qafղ 7 iL@|u'tzinfo-1.2.2/LICENSE0000644000004100000410000000206012400401360014046 0ustar www-datawww-dataCopyright (c) 2005-2014 Philip Ross Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tzinfo-1.2.2/CHANGES.md0000644000004100000410000006300012400401360014434 0ustar www-datawww-dataVersion 1.2.2 - 8-Aug-2014 -------------------------- * Fix an error with duplicates being returned by Timezone#all_country_zones and Timezone#all_country_zone_identifiers when used with tzinfo-data v1.2014.6 or later. * Use the zone1970.tab file for country timezone data if it is found in the zoneinfo directory (and fallback to zone.tab if not). zone1970.tab was added in tzdata 2014f. zone.tab is now deprecated. Version 1.2.1 - 1-Jun-2014 -------------------------- * Support zoneinfo files generated with zic version 2014c and later. * On platforms that only support positive 32-bit timestamps, ensure that conversions are accurate from the epoch instead of just from the first transition after the epoch. * Minor documentation improvements. Version 1.2.0 - 26-May-2014 --------------------------- * Raise the minimum supported Ruby version to 1.8.7. * Support loading system zoneinfo data on FreeBSD, OpenBSD and Solaris. Resolves #15. * Add canonical_identifier and canonical_zone methods to Timezone. Resolves #16. * Add a link to a DataSourceNotFound help page in the TZInfo::DataSourceNotFound exception message. * Load iso3166.tab and zone.tab files as UTF-8. * Fix Timezone#local_to_utc returning local Time instances on systems using UTC as the local time zone. Resolves #13. * Fix == methods raising an exception when passed an instance of a different class by making <=> return nil if passed a non-comparable argument. * Eliminate "require 'rational'" warnings. Resolves #10. * Eliminate "assigned but unused variable - info" warnings. Resolves #11. * Switch to minitest v5 for unit tests. Resolves #18. Version 1.1.0 - 25-Sep-2013 --------------------------- * TZInfo is now thread safe. ThreadSafe::Cache is now used instead of Hash to cache Timezone and Country instances returned by Timezone.get and Country.get. The tzinfo gem now depends on thread_safe ~> 0.1. * Added a transitions_up_to method to Timezone that returns a list of the times where the UTC offset of the timezone changes. * Added an offsets_up_to method to Timezone that returns the set of offsets that have been observed in a defined timezone. * Fixed a "can't modify frozen String" error when loading a Timezone from a zoneinfo file using an identifier String that is both tainted and frozen. Resolves #3. * Support TZif3 format zoneinfo files (now produced by zic from tzcode version 2013e onwards). * Support using YARD to generate documentation (added a .yardopts file). * Ignore the +VERSION file included in the zoneinfo directory on Mac OS X. * Added a note to the documentation concerning 32-bit zoneinfo files (as included with Mac OS X). Version 1.0.1 - 22-Jun-2013 --------------------------- * Fix a test case failure when tests are run from a directory that contains a dot in the path (issue #29751). Version 1.0.0 - 2-Jun-2013 -------------------------- * Allow TZInfo to be used with different data sources instead of just the built-in Ruby module data files. * Include a data source that allows TZInfo to load data from the binary zoneinfo files produced by zic and included with many Linux and Unix-like distributions. * Remove the definition and index Ruby modules from TZInfo and move them into a separate TZInfo::Data library (available as the tzinfo-data gem). * Default to using the TZInfo::Data library as the data source if it is installed, otherwise use zoneinfo files instead. * Preserve the nanoseconds of local timezone Time objects when performing conversions (issue #29705). * Don't add the tzinfo lib directory to the search path when requiring 'tzinfo'. The tzinfo lib directory must now be in the search path before 'tzinfo' is required. * Add utc_start_time, utc_end_time, local_start_time and local_end_time instance methods to TimezonePeriod. These return an identical value as the existing utc_start, utc_end, local_start and local_end methods, but return Time instances instead of DateTime. * Make the start_transition, end_transition and offset properties of TimezonePeriod protected. To access properties of the period, callers should use other TimezonePeriod instance methods instead (issue #7655). Version 0.3.39 (tzdata v2014a) - 9-Mar-2014 ------------------------------------------- * Updated to tzdata version 2014a (http://mm.icann.org/pipermail/tz-announce/2014-March/000018.html). Version 0.3.38 (tzdata v2013g) - 8-Oct-2013 ------------------------------------------- * Updated to tzdata version 2013g (http://mm.icann.org/pipermail/tz-announce/2013-October/000015.html). Version 0.3.37 (tzdata v2013b) - 11-Mar-2013 -------------------------------------------- * Updated to tzdata version 2013b (http://mm.icann.org/pipermail/tz-announce/2013-March/000010.html). Version 0.3.36 (tzdata v2013a) - 3-Mar-2013 ------------------------------------------- * Updated to tzdata version 2013a (http://mm.icann.org/pipermail/tz-announce/2013-March/000009.html). * Fix TimezoneTransitionInfo#eql? incorrectly returning false when running on Ruby 2.0. * Change eql? and == implementations to test the class of the passed in object instead of checking individual properties with 'respond_to?'. Version 0.3.35 (tzdata v2012i) - 4-Nov-2012 ------------------------------------------- * Updated to tzdata version 2012i (http://mm.icann.org/pipermail/tz-announce/2012-November/000007.html). Version 0.3.34 (tzdata v2012h) - 27-Oct-2012 -------------------------------------------- * Updated to tzdata version 2012h (http://mm.icann.org/pipermail/tz-announce/2012-October/000006.html). Version 0.3.33 (tzdata v2012c) - 8-Apr-2012 ------------------------------------------- * Updated to tzdata version 2012c (http://article.gmane.org/gmane.comp.time.tz/4859). Version 0.3.32 (tzdata v2012b) - 4-Mar-2012 ------------------------------------------- * Updated to tzdata version 2012b (http://article.gmane.org/gmane.comp.time.tz/4756). Version 0.3.31 (tzdata v2011n) - 6-Nov-2011 ------------------------------------------- * Updated to tzdata version 2011n (http://article.gmane.org/gmane.comp.time.tz/4434). Version 0.3.30 (tzdata v2011k) - 29-Sep-2011 -------------------------------------------- * Updated to tzdata version 2011k (http://article.gmane.org/gmane.comp.time.tz/4084). Version 0.3.29 (tzdata v2011h) - 27-Jun-2011 -------------------------------------------- * Updated to tzdata version 2011h (http://article.gmane.org/gmane.comp.time.tz/3814). * Allow the default value of the local_to_utc and period_for_local dst parameter to be specified globally with a Timezone.default_dst attribute. Thanks to Kurt Werle for the suggestion and patch. Version 0.3.28 (tzdata v2011g) - 13-Jun-2011 --------------------------------------------= * Add support for Ruby 1.9.3 (trunk revision 31668 and later). Thanks to Aaron Patterson for reporting the problems running on the new version. Closes #29233. Version 0.3.27 (tzdata v2011g) - 26-Apr-2011 -------------------------------------------- * Updated to tzdata version 2011g (http://article.gmane.org/gmane.comp.time.tz/3758). Version 0.3.26 (tzdata v2011e) - 2-Apr-2011 ------------------------------------------- * Updated to tzdata version 2011e (http://article.gmane.org/gmane.comp.time.tz/3707). Version 0.3.25 (tzdata v2011d) - 14-Mar-2011 -------------------------------------------- * Updated to tzdata version 2011d (http://article.gmane.org/gmane.comp.time.tz/3662). Version 0.3.24 (tzdata v2010o) - 15-Jan-2011 -------------------------------------------- * Updated to tzdata version 2010o (http://article.gmane.org/gmane.comp.time.tz/3473). Version 0.3.23 (tzdata v2010l) - 19-Aug-2010 -------------------------------------------- * Updated to tzdata version 2010l (http://article.gmane.org/gmane.comp.time.tz/3354). Version 0.3.22 (tzdata v2010j) - 29-May-2010 -------------------------------------------- * Corrected file permissions issue with 0.3.21 release. Version 0.3.21 (tzdata v2010j) - 28-May-2010 -------------------------------------------- * Updated to tzdata version 2010j (http://article.gmane.org/gmane.comp.time.tz/3225). * Change invalid timezone check to exclude characters not used in timezone identifiers and avoid 'character class has duplicated range' warnings with Ruby 1.9.2. * Ruby 1.9.2 has deprecated "require 'rational'", but older versions of Ruby need rational to be required. Require rational only when the Rational module has not already been loaded. * Remove circular requires (now a warning in Ruby 1.9.2). Instead of using requires in each file for dependencies, tzinfo.rb now requires all tzinfo files. If you were previously requiring files within the tzinfo directory (e.g. require 'tzinfo/timezone'), then you will now have to require 'tzinfo' instead. Version 0.3.20 (tzdata v2010i) - 19-Apr-2010 -------------------------------------------- * Updated to tzdata version 2010i (http://article.gmane.org/gmane.comp.time.tz/3202). Version 0.3.19 (tzdata v2010h) - 5-Apr-2010 ------------------------------------------- * Updated to tzdata version 2010h (http://article.gmane.org/gmane.comp.time.tz/3188). Version 0.3.18 (tzdata v2010g) - 29-Mar-2010 -------------------------------------------- * Updated to tzdata version 2010g (http://article.gmane.org/gmane.comp.time.tz/3172). Version 0.3.17 (tzdata v2010e) - 8-Mar-2010 ------------------------------------------- * Updated to tzdata version 2010e (http://article.gmane.org/gmane.comp.time.tz/3128). Version 0.3.16 (tzdata v2009u) - 5-Jan-2010 ------------------------------------------- * Support the use of '-' to denote '0' as an offset in the tz data files. Used for the first time in the SAVE field in tzdata v2009u. * Updated to tzdata version 2009u (http://article.gmane.org/gmane.comp.time.tz/3053). Version 0.3.15 (tzdata v2009p) - 26-Oct-2009 -------------------------------------------- * Updated to tzdata version 2009p (http://article.gmane.org/gmane.comp.time.tz/2953). * Added a description to the gem spec. * List test files in test_files instead of files in the gem spec. Version 0.3.14 (tzdata v2009l) - 19-Aug-2009 -------------------------------------------- * Updated to tzdata version 2009l (http://article.gmane.org/gmane.comp.time.tz/2818). * Include current directory in load path to allow running tests on Ruby 1.9.2, which doesn't include it by default any more. Version 0.3.13 (tzdata v2009f) - 15-Apr-2009 -------------------------------------------- * Updated to tzdata version 2009f (http://article.gmane.org/gmane.comp.time.tz/2668). * Untaint the timezone module filename after validation to allow use with $SAFE == 1 (e.g. under mod_ruby). Thanks to Dmitry Borodaenko for the suggestion. Closes #25349. Version 0.3.12 (tzdata v2008i) - 12-Nov-2008 -------------------------------------------- * Updated to tzdata version 2008i (http://article.gmane.org/gmane.comp.time.tz/2440). Version 0.3.11 (tzdata v2008g) - 7-Oct-2008 ------------------------------------------- * Updated to tzdata version 2008g (http://article.gmane.org/gmane.comp.time.tz/2335). * Support Ruby 1.9.0-5. Rational.new! has now been removed in Ruby 1.9. Only use Rational.new! if it is available (it is preferable in Ruby 1.8 for performance reasons). Thanks to Jeremy Kemper and Pratik Naik for reporting this. Closes #22312. * Apply a patch from Pratik Naik to replace assert calls that have been deprecated in the Ruby svn trunk. Closes #22308. Version 0.3.10 (tzdata v2008f) - 16-Sep-2008 -------------------------------------------- * Updated to tzdata version 2008f (http://article.gmane.org/gmane.comp.time.tz/2293). Version 0.3.9 (tzdata v2008c) - 27-May-2008 ------------------------------------------- * Updated to tzdata version 2008c (http://article.gmane.org/gmane.comp.time.tz/2183). * Support loading timezone data in the latest trunk versions of Ruby 1.9. Rational.new! is now private, so call it using Rational.send :new! instead. Thanks to Jeremy Kemper and Pratik Naik for spotting this. Closes #19184. * Prevent warnings from being output when running Ruby with the -v or -w command line options. Thanks to Paul McMahon for the patch. Closes #19719. Version 0.3.8 (tzdata v2008b) - 24-Mar-2008 ------------------------------------------- * Updated to tzdata version 2008b (http://article.gmane.org/gmane.comp.time.tz/2149). * Support loading timezone data in Ruby 1.9.0. Use DateTime.new! if it is available instead of DateTime.new0 when constructing transition times. DateTime.new! was added in Ruby 1.8.6. DateTime.new0 was removed in Ruby 1.9.0. Thanks to Joshua Peek for reporting this. Closes #17606. * Modify some of the equality test cases to cope with the differences between Ruby 1.8.6 and Ruby 1.9.0. Version 0.3.7 (tzdata v2008a) - 10-Mar-2008 ------------------------------------------- * Updated to tzdata version 2008a (http://article.gmane.org/gmane.comp.time.tz/2071). Version 0.3.6 (tzdata v2007k) - 1-Jan-2008 ------------------------------------------ * Updated to tzdata version 2007k (http://article.gmane.org/gmane.comp.time.tz/2029). * Removed deprecated RubyGems autorequire option. Version 0.3.5 (tzdata v2007h) - 1-Oct-2007 ------------------------------------------ * Updated to tzdata version 2007h (http://article.gmane.org/gmane.comp.time.tz/1878). Version 0.3.4 (tzdata v2007g) - 21-Aug-2007 ------------------------------------------- * Updated to tzdata version 2007g (http://article.gmane.org/gmane.comp.time.tz/1810). Version 0.3.3 (tzdata v2006p) - 27-Nov-2006 ------------------------------------------- * Updated to tzdata version 2006p (http://article.gmane.org/gmane.comp.time.tz/1358). Version 0.3.2 (tzdata v2006n) - 11-Oct-2006 ------------------------------------------- * Updated to tzdata version 2006n (http://article.gmane.org/gmane.comp.time.tz/1288). Note that this release of tzdata removes the country Serbia and Montenegro (CS) and replaces it with separate Serbia (RS) and Montenegro (ME) entries. Version 0.3.1 (tzdata v2006j) - 21-Aug-2006 ------------------------------------------- * Remove colon from case statements to avoid warning in Ruby 1.8.5. #5198. * Use temporary variable to avoid dynamic string warning from rdoc. * Updated to tzdata version 2006j (http://article.gmane.org/gmane.comp.time.tz/1175). Version 0.3.0 (tzdata v2006g) - 17-Jul-2006 ------------------------------------------- * New timezone data format. Timezone data now occupies less space on disk and takes less memory once loaded. #4142, #4144. * Timezone data is defined in modules rather than classes. Timezone instances returned by Timezone.get are no longer instances of data classes, but are instead instances of new DataTimezone and LinkedTimezone classes. * Timezone instances can now be used with Marshal.dump and Marshal.load. #4240. * Added a Timezone.get_proxy method that returns a TimezoneProxy object for a given identifier. * Country index data is now defined in a single module that is independent of the Country class implementation. * Country instances can now be used with Marshal.dump and Marshal.load. #4240. * Country has a new zone_info method that returns CountryTimezone objects containing additional information (latitude, longitude and a description) relating to each Timezone. #4140. * Timezones within a Country are now returned in an order that makes geographic sense. * The zdumptest utility now checks local to utc conversions in addition to utc to local conversions. * eql? method defined on Country and Timezone that is equivalent to ==. * The == method of Timezone no longer raises an exception when passed an object with no identifier method. * The == method of Country no longer raises an exception when passed an object with no code method. * hash method defined on Country that returns the hash of the code. * hash method defined on Timezone that returns the hash of the identifier. * Miscellaneous API documentation corrections and improvements. * Timezone definition and indexes are now excluded from rdoc (the contents were previously ignored with #:nodoc: anyway). * Removed no longer needed #:nodoc: directives from timezone data files (which are now excluded from the rdoc build). * Installation of the gem now causes rdoc API documentation to be generated. #4905. * When optimizing transitions to generate zone definitions, check the UTC and standard offsets separately rather than just the total offset to UTC. Fixes an incorrect abbreviation issue with Europe/London, Europe/Dublin and Pacific/Auckland. * Eliminated unnecessary .nil? calls to give a minor performance gain. * Timezone.all and Timezone.all_identifiers now return all the Timezones/identifiers rather than just those associated with countries. #4146. * Added all_data_zones, all_data_zone_identifiers, all_linked_zones and all_linked_zone_identifiers class methods to Timezone. * Added a strftime method to Timezone that converts a time in UTC to local time and then returns it formatted. %Z is replaced with the Timezone abbreviation for the given time (for example, EST or EDT). #4143. * Fix escaping of quotes in TZDataParser. This affected country names and descriptions of timezones within countries. Version 0.2.2 (tzdata v2006g) - 17-May-2006 ------------------------------------------- * Use class-scoped instance variables to store the Timezone identifier and singleton instance. Loading a linked zone no longer causes the parent zone's identifier to be changed. The instance method of a linked zone class also now returns an instance of the linked zone class rather than the parent class. #4502. * The zdumptest utility now compares the TZInfo zone identifier with the zdump zone identifier. * The zdumptestall utility now exits if not supplied with enough parameters. * Updated to tzdata version 2006g (http://article.gmane.org/gmane.comp.time.tz/1008). Version 0.2.1 (tzdata v2006d) - 17-Apr-2006 ------------------------------------------- * Fix a performance issue caused in 0.2.0 with Timezone.local_to_utc. Conversions performed on TimeOrDateTime instances passed to <=> are now cached as originally intended. Thanks to Michael Smedberg for spotting this. * Fix a performance issue with the local_to_utc period search algorithm originally implemented in 0.1.0. The condition that was supposed to cause the search to terminate when enough periods had been found was only being evaluated in a small subset of cases. Thanks to Michael Smedberg and Jamis Buck for reporting this. * Added abbreviation as an alias for TimezonePeriod.zone_identifier. * Updated to tzdata version 2006d (http://article.gmane.org/gmane.comp.time.tz/936). * Ignore any offset in DateTimes passed in (as is already done for Times). All of the following now refer to the same UTC time (15:40 on 17 April 2006). Previously, the DateTime in the second line would have been interpreted as 20:40. tz.utc_to_local(DateTime.new(2006, 4, 17, 15, 40, 0)) tz.utc_to_local(DateTime.new(2006, 4, 17, 15, 40, 0).new_offset(Rational(5, 24))) tz.utc_to_local(Time.utc(2006, 4, 17, 15, 40, 0)) tz.utc_to_local(Time.local(2006, 4, 17, 15, 40, 0)) Version 0.2.0 (tzdata v2006c) - 3-Apr-2006 ------------------------------------------ * Use timestamps rather than DateTime objects in zone files for times between 1970 and 2037 (the range of Time). * Don't convert passed in Time objects to DateTime in most cases (provides a substantial performance improvement). * Allow integer timestamps (time in seconds since 1970-1-1) to be used as well as Time and DateTime objects in all public methods that take times as parameters. * Tool to compare TZInfo conversions with output from zdump. * TZDataParser zone generation algorithm rewritten. Now based on the zic code. TZInfo is now 100% compatible with zic/zdump output. * Riyadh Solar Time zones now included again (generation time has been reduced with TZDataParser changes). * Use binary mode when writing zone and country files to get Unix (\n) new lines. * Omit unnecessary quotes in zone identifier symbols. * Omit the final transition to DST if there is a prior transition in the last year processed to standard time. * Updated to tzdata version 2006c (http://article.gmane.org/gmane.comp.time.tz/920). Version 0.1.2 (tzdata v2006a) - 5-Feb-2006 ------------------------------------------ * Add lib directory to the load path when tzinfo is required. Makes it easier to use tzinfo gem when unpacked to vendor directory in rails. * Updated to tzdata version 2006a (http://article.gmane.org/gmane.comp.time.tz/738). * build_tz_classes rake task now handles running svn add and svn delete as new timezones and countries are added and old ones are removed. * Return a better error when attempting to use a Timezone instance that was constructed with Timezone.new(nil). This will occur when using Rails' composed_of. When the timezone identifier in the database is null, attempting to use the Timezone will now result in an UnknownTimezone exception rather than a NameError. Version 0.1.1 (tzdata v2005q) - 18-Dec-2005 ------------------------------------------- * Timezones that are defined by a single unbounded period (e.g. UTC) now work again. * Updated to tzdata version 2005q. Version 0.1.0 (tzdata v2005n) - 27-Nov-2005 ------------------------------------------- * period_for_local and local_to_utc now allow resolution of ambiguous times (e.g. when switching from daylight savings to standard time). The behaviour of these methods when faced with an ambiguous local time has now changed. If you are using these methods you should check the documentation. Thanks to Cliff Matthews for suggesting this change. * Added require 'date' to timezone.rb (date isn't loaded by default in all environments). * Use rake to build packages and documentation. * License file is now included in gem distribution. * Dates in definitions stored as Astronomical Julian Day numbers rather than as civil dates (improves performance creating DateTime instances). * Added options to TZDataParser to allow generation of specific zones and countries. * Moved TimezonePeriod class to timezone_period.rb. * New TimezonePeriodList class to store TimezonePeriods for a timezone and perform searches for periods. * Timezones now defined using blocks. TimezonePeriods are only instantiated when they are needed. Thanks to Jamis Buck for the suggestion. * Add options to TZDataParser to allow exclusion of specific zones and countries. * Exclude the Riyadh Solar Time zones. The rules are only for 1987 to 1989 and take a long time to generate and process. Riyadh Solar Time is no longer observed. * The last TimezonePeriod for each Timezone is now written out with an unbounded rather than arbitrary end time. * Construct the Rational offset in TimezonePeriod once when the TimezonePeriod is constructed rather than each time it is needed. * Timezone and Country now keep a cache of loaded instances to avoid running require which can be slow on some platforms. * Updated to tzdata version 2005n. Version 0.0.4 (tzdata v2005m) - 18-Sep-2005 ------------------------------------------- * Removed debug output accidentally included in the previous release. * Fixed a bug in the generation of friendly zone identifiers (was inserting apostrophes into UTC, GMT, etc). * Fixed Country <=> operator (was comparing non-existent attribute) * Fixed Timezone.period_for_local error when period not found. * Added testcases for Timezone, TimezoneProxy, TimezonePeriod, Country and some selected timezones. Version 0.0.3 (tzdata v2005m) - 17-Sep-2005 ------------------------------------------- * Reduced visibility of some methods added in Timezone#setup and Country#setup. * Added name method to Timezone (returns the identifier). * Added friendly_identifier method to Timezone. Returns a more friendly version of the identifier. * Added to_s method to Timezone. Returns the friendly identifier. * Added == and <=> operators to Timezone (compares identifiers). * Timezone now includes Comparable. * Added to_s method to Country. * Added == and <=> operators to Country (compares ISO 3166 country codes). * Country now includes Comparable. * New TimezoneProxy class that behaves the same as a Timezone but doesn't actually load in its definition until it is actually required. * Modified Timezone and Country methods that return Timezones to return TimezoneProxy instances instead. This makes these methods much quicker. In Ruby on Rails, you can now show a drop-down list of all timezones using the Rails time_zone_select helper method: <%= time_zone_select 'user', 'time_zone', TZInfo::Timezone.all.sort, :model => TZInfo::Timezone %> Version 0.0.2 (tzdata v2005m) - 13-Sep-2005 ------------------------------------------- * Country and Timezone data is now loaded into class rather than instance variables. This makes Timezone links more efficient and saves memory if creating specific Timezone and Country classes directly. * TimezonePeriod zone_identifier is now defined as a symbol to save memory (was previously a string). * TimezonePeriod zone_identifiers that were previously '' are now :Unknown. * Timezones and Countries can now be returned using Timezone.new(identifier) and Country.new(identifier). When passed an identifier, the new method calls get to return an instance of the specified timezone or country. * Added new class methods to Timezone to return sets of zones and identifiers. Thanks to Scott Barron of Lunchbox Software for the suggestions in his article about using TZInfo with Rails (http://lunchroom.lunchboxsoftware.com/pages/tzinfo_rails) Version 0.0.1 (tzdata v2005m) - 29-Aug-2005 ------------------------------------------- * First release. tzinfo-1.2.2/tzinfo.gemspec0000644000004100000410000000171612400401360015726 0ustar www-datawww-dataGem::Specification.new do |s| s.name = 'tzinfo' s.version = '1.2.2' s.summary = 'Daylight savings aware timezone library' s.description = 'TZInfo provides daylight savings aware transformations between times in different time zones.' s.author = 'Philip Ross' s.email = 'phil.ross@gmail.com' s.homepage = 'http://tzinfo.github.io' s.license = 'MIT' s.files = %w(CHANGES.md LICENSE Rakefile README.md tzinfo.gemspec .yardopts) + Dir['lib/**/*.rb'].delete_if {|f| f.include?('.svn')} + Dir['test/**/*.rb'].delete_if {|f| f.include?('.svn')} + Dir['test/zoneinfo/**/*'].delete_if {|f| f.include?('.svn') || File.symlink?(f)} s.platform = Gem::Platform::RUBY s.require_path = 'lib' s.rdoc_options << '--title' << 'TZInfo' << '--main' << 'README.md' s.extra_rdoc_files = ['README.md', 'CHANGES.md', 'LICENSE'] s.required_ruby_version = '>= 1.8.7' s.add_dependency 'thread_safe', '~> 0.1' end tzinfo-1.2.2/metadata.gz.sig0000444000004100000410000000040012400401360015736 0ustar www-datawww-datan (?q 4!B "]Eiإ/ u.*1陆jtE6iՒ0BToP15 ~658> `kn|irhB2`^#64t0swzJ?,sN ; 4v6w>Qn$HR@6_>պS s?fAвv+oYU V W)^IVF(aF!a&T˄$6tzinfo-1.2.2/README.md0000644000004100000410000001232512400401360014325 0ustar www-datawww-dataTZInfo - Ruby Timezone Library ============================== [![Gem Version](https://badge.fury.io/rb/tzinfo.svg)](http://badge.fury.io/rb/tzinfo) [![Build Status](https://travis-ci.org/tzinfo/tzinfo.svg?branch=master)](https://travis-ci.org/tzinfo/tzinfo) [TZInfo](http://tzinfo.github.io) provides daylight savings aware transformations between times in different timezones. Data Sources ------------ TZInfo requires a source of timezone data. There are two built-in options: 1. The TZInfo::Data library (the tzinfo-data gem). TZInfo::Data contains a set of Ruby modules that are generated from the [IANA Time Zone Database](http://www.iana.org/time-zones). 2. A zoneinfo directory. Most Unix-like systems include a zoneinfo directory containing timezone definitions. These are also generated from the [IANA Time Zone Database](http://www.iana.org/time-zones). By default, TZInfo::Data will be used. If TZInfo::Data is not available (i.e. if `require 'tzinfo/data'` fails), then TZInfo will search for a zoneinfo directory instead (using the search path specified by `TZInfo::ZoneinfoDataSource::DEFAULT_SEARCH_PATH`). If no data source can be found, a `TZInfo::DataSourceNotFound` exception will be raised when TZInfo is used. Further information is available [in the wiki](http://tzinfo.github.io/datasourcenotfound) to help with resolving `TZInfo::DataSourceNotFound` errors. The default data source selection can be overridden using `TZInfo::DataSource.set`. Custom data sources can also be used. See `TZInfo::DataSource.set` for further details. Installation ------------ The TZInfo gem can be installed by running: gem install tzinfo To use the Ruby modules as the data source, TZInfo::Data will also need to be installed: gem install tzinfo-data Example Usage ------------- The following code will obtain the America/New_York timezone (as an instance of `TZInfo::Timezone`) and convert a time in UTC to local New York time: require 'tzinfo' tz = TZInfo::Timezone.get('America/New_York') local = tz.utc_to_local(Time.utc(2005,8,29,15,35,0)) Note that the local Time returned will have a UTC timezone (`local.zone` will return `"UTC"`). This is because the Ruby Time class only supports two timezones: UTC and the current system local timezone. To convert from a local time to UTC, the `local_to_utc` method can be used as follows: utc = tz.local_to_utc(local) Note that the timezone information of the local Time object is ignored (TZInfo will just read the date and time and treat them as if there were in the `tz` timezone). The following two lines will return the same result regardless of the system's local timezone: tz.local_to_utc(Time.local(2006,6,26,1,0,0)) tz.local_to_utc(Time.utc(2006,6,26,1,0,0)) To obtain information about the rules in force at a particular UTC or local time, the `TZInfo::Timezone.period_for_utc` and `TZInfo::Timezone.period_for_local` methods can be used. Both of these methods return `TZInfo::TimezonePeriod` objects. The following gets the identifier for the period (in this case EDT). period = tz.period_for_utc(Time.utc(2005,8,29,15,35,0)) id = period.zone_identifier The current local time in a `Timezone` can be obtained with the `TZInfo::Timezone#now` method: now = tz.now All methods in TZInfo that operate on a time can be used with either `Time` or `DateTime` instances or with Integer timestamps (i.e. as returned by `Time#to_i`). The type of the values returned will match the type passed in. A list of all the available timezone identifiers can be obtained using the `TZInfo::Timezone.all_identifiers` method. `TZInfo::Timezone.all` can be called to get an `Array` of all the `TZInfo::Timezone` instances. Timezones can also be accessed by country (using an ISO 3166-1 alpha-2 country code). The following code retrieves the `TZInfo::Country` instance representing the USA (country code 'US') and then gets all the timezone identifiers used in the USA. us = TZInfo::Country.get('US') timezones = us.zone_identifiers The `TZInfo::Country#zone_info` method provides an additional description and geographic location for each timezone in a country. A list of all the available country codes can be obtained using the `TZInfo::Country.all_codes` method. `TZInfo::Country.all` can be called to get an `Array` of all the `Country` instances. For further detail, please refer to the API documentation for the `TZInfo::Timezone` and `TZInfo::Country` classes. Thread-Safety ------------- The `TZInfo::Country` and `TZInfo::Timezone` classes are thread-safe. It is safe to use class and instance methods of `TZInfo::Country` and `TZInfo::Timezone` in concurrently executing threads. Instances of both classes can be shared across thread boundaries. Documentation ------------- API documentation for TZInfo is available on [RubyDoc.info](http://rubydoc.info/gems/tzinfo/frames). License ------- TZInfo is released under the MIT license, see LICENSE for details. Source Code ----------- Source code for TZInfo is available on [GitHub](https://github.com/tzinfo/tzinfo). Issue Tracker ------------- Please post any bugs, issues, feature requests or questions to the [GitHub issue tracker](https://github.com/tzinfo/tzinfo/issues).