class TimeWithZoneMethodsForDate

Public Instance Methods

setup() click to toggle source
# File activesupport/test/core_ext/time_with_zone_test.rb, line 1203
def setup
  @d = Date.civil(2000)
end
test_in_time_zone() click to toggle source
# File activesupport/test/core_ext/time_with_zone_test.rb, line 1207
def test_in_time_zone
  with_tz_default "Alaska" do
    assert_equal "Sat, 01 Jan 2000 00:00:00 AKST -09:00", @d.in_time_zone.inspect
  end
  with_tz_default "Hawaii" do
    assert_equal "Sat, 01 Jan 2000 00:00:00 HST -10:00", @d.in_time_zone.inspect
  end
  with_tz_default nil do
    assert_equal @d.to_time, @d.in_time_zone
  end
end
test_in_time_zone_with_argument() click to toggle source
# File activesupport/test/core_ext/time_with_zone_test.rb, line 1225
def test_in_time_zone_with_argument
  with_tz_default "Eastern Time (US & Canada)" do # Time.zone will not affect #in_time_zone(zone)
    assert_equal "Sat, 01 Jan 2000 00:00:00 AKST -09:00", @d.in_time_zone("Alaska").inspect
    assert_equal "Sat, 01 Jan 2000 00:00:00 HST -10:00", @d.in_time_zone("Hawaii").inspect
    assert_equal "Sat, 01 Jan 2000 00:00:00 UTC +00:00", @d.in_time_zone("UTC").inspect
    assert_equal "Sat, 01 Jan 2000 00:00:00 AKST -09:00", @d.in_time_zone(-9.hours).inspect
  end
end
test_in_time_zone_with_invalid_argument() click to toggle source
# File activesupport/test/core_ext/time_with_zone_test.rb, line 1234
def test_in_time_zone_with_invalid_argument
  assert_raise(ArgumentError) { @d.in_time_zone("No such timezone exists") }
  assert_raise(ArgumentError) { @d.in_time_zone(-15.hours) }
  assert_raise(ArgumentError) { @d.in_time_zone(Object.new) }
end
test_nil_time_zone() click to toggle source
# File activesupport/test/core_ext/time_with_zone_test.rb, line 1219
def test_nil_time_zone
  with_tz_default nil do
    assert !@d.in_time_zone.respond_to?(:period), "no period method"
  end
end