1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
require "../spec_helper"
class Time::Location
def __cached_zone=(zone)
@cached_zone = zone
end
def self.__clear_location_cache
@@location_cache.clear
end
end
def with_env(name, value)
previous = ENV[name]?
begin
ENV[name] = value
# Reset local time zone
Time::Location.local = Time::Location.load_local
yield
ensure
ENV[name] = previous
end
end
ZONEINFO_ZIP = datapath("zoneinfo.zip")
def with_zoneinfo(path = ZONEINFO_ZIP)
with_env("ZONEINFO", path) do
Time::Location.__clear_location_cache
yield
end
end
|