Sha256: fccfd11742a43c73f31f5d9a0075b0367ee82f9399602fe5e9575dabce4414af

Contents?: true

Size: 1.8 KB

Versions: 260

Compression:

Stored size: 1.8 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require 'test/unit'
require 'tzinfo'

include TZInfo

class TCDataTimezone < Test::Unit::TestCase
  
  class TestTimezoneInfo < TimezoneInfo
    attr_reader :utc
    attr_reader :local
    
    def initialize(identifier, utc_period, local_periods)
      super(identifier)
      @utc_period = utc_period
      @local_periods = local_periods || []
    end
    
    def period_for_utc(utc)
      @utc = utc
      @utc_period     
    end
    
    def periods_for_local(local)
      @local = local      
      @local_periods
    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    
end

Version data entries

260 entries across 183 versions & 18 rubygems

Version Path
tzinfo-0.3.62 test/tc_data_timezone.rb
tzinfo-0.3.61 test/tc_data_timezone.rb
tzinfo-0.3.60 test/tc_data_timezone.rb
tzinfo-0.3.59 test/tc_data_timezone.rb
tzinfo-0.3.58 test/tc_data_timezone.rb
tzinfo-0.3.57 test/tc_data_timezone.rb
tzinfo-0.3.56 test/tc_data_timezone.rb
tzinfo-0.3.55 test/tc_data_timezone.rb
tzinfo-0.3.54 test/tc_data_timezone.rb
tzinfo-0.3.53 test/tc_data_timezone.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/tzinfo-0.3.52/test/tc_data_timezone.rb
tzinfo-0.3.52 test/tc_data_timezone.rb
tzinfo-0.3.51 test/tc_data_timezone.rb
tzinfo-0.3.50 test/tc_data_timezone.rb
tzinfo-0.3.49 test/tc_data_timezone.rb
tzinfo-0.3.48 test/tc_data_timezone.rb
tzinfo-0.3.47 test/tc_data_timezone.rb
tzinfo-0.3.46 test/tc_data_timezone.rb
tzinfo-0.3.45 test/tc_data_timezone.rb
classiccms-0.7.5 vendor/bundle/gems/tzinfo-0.3.32/test/tc_data_timezone.rb