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
dirty_history-0.4.9 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.6 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.5 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.4 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.3 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
dirty_history-0.4.2 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
tzinfo-0.3.31 test/tc_data_timezone.rb
dirty_history-0.3.0 dirty_history/ruby/1.9.1/gems/tzinfo-0.3.30/test/tc_data_timezone.rb
tzinfo-0.3.30 test/tc_data_timezone.rb
tzinfo-0.3.29 test/tc_data_timezone.rb
tzinfo-0.3.28 test/tc_data_timezone.rb
tzinfo-0.3.27 test/tc_data_timezone.rb
tzinfo-0.3.26 test/tc_data_timezone.rb
tzinfo-0.3.25 test/tc_data_timezone.rb
tzinfo-0.3.24 test/tc_data_timezone.rb
tzinfo-0.3.23 test/tc_data_timezone.rb
tzinfo-0.3.22 test/tc_data_timezone.rb
tzinfo-0.3.21 test/tc_data_timezone.rb