Sha256: 8afabb0f721b8f35b596610f6f41ebc8ca17a0f48717c70ccbbbb8eddefd8b9e
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../lib/timezone') require File.expand_path(File.dirname(__FILE__) + '/../lib/timezone/zone') require File.expand_path(File.dirname(__FILE__) + '/../lib/timezone/error') require File.expand_path(File.dirname(__FILE__) + '/../lib/timezone/configure') require 'test/unit' class TimezoneTest < Test::Unit::TestCase def test_valid_timezone assert_nothing_raised do Timezone::Zone.new :zone => 'Australia/Sydney' end end def test_nil_timezone assert_raise Timezone::Error::NilZone do Timezone::Zone.new :zone => nil end end def test_invalid_timezone assert_raise Timezone::Error::InvalidZone do Timezone::Zone.new :zone => 'Foo/Bar' end end def test_loading_GMT_timezone timezone = Timezone::Zone.new :zone => 'GMT' assert_equal Time.now.utc.to_i, timezone.time(Time.now).to_i end def test_loading_historical_time timezone = Timezone::Zone.new :zone => 'America/Los_Angeles' local = Time.strptime('2011-02-11T13:20:00Z', '%Y-%m-%dT%H:%M:%SZ') utc = Time.strptime('2011-02-11T21:20:00Z', '%Y-%m-%dT%H:%M:%SZ') assert_equal local.to_i, timezone.time(utc).to_i end def test_loading_half_hour_timezone timezone = Timezone::Zone.new :zone => 'Asia/Kathmandu' utc = Time.utc(2011, 1, 4, 3, 51, 29) local = Time.utc(2011, 1, 4, 9, 36, 29) assert_equal local.to_i, timezone.time(utc).to_i end def test_using_lat_lon_coordinates Timezone::Configure.begin { |c| c.username = 'timezone' } timezone = Timezone::Zone.new :latlon => [-34.92771808058, 138.477041423321] assert_equal 'Australia/Adelaide', timezone.zone end def test_australian_timezone_with_dst timezone = Timezone::Zone.new :zone => 'Australia/Adelaide' utc = Time.utc(2010, 12, 23, 19, 37, 15) local = Time.utc(2010, 12, 24, 6, 7, 15) assert_equal local.to_i, timezone.time(utc).to_i end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
timezone-0.1.0 | test/timezone_test.rb |