Sha256: 1721d139aaf046f9e8786f69be157fa0dd19e40099eadbd3dbeba2d0bf628d4f
Contents?: true
Size: 1.6 KB
Versions: 7
Compression:
Stored size: 1.6 KB
Contents
require 'spec_helper' require 'gorillib/datetime/to_flat' require 'gorillib/datetime/parse' describe Time, :datetime_spec => true do describe '#parse_safely' do before do @time_utc = Time.parse("2011-02-03T04:05:06 UTC") @time_cst = Time.parse("2011-02-02T22:05:06-06:00") @time_flat = "20110203040506" @time_iso_utc = "2011-02-03T04:05:06+00:00" @time_iso_cst = "2011-02-02T22:05:06-06:00" end it 'with a Time, passes it through.' do Time.parse_safely(@time_utc).should == @time_utc Time.parse_safely(@time_cst).should == @time_cst end it 'with a Time, converts to UTC.' do Time.parse_safely(@time_utc).utc_offset.should == 0 Time.parse_safely(@time_cst).utc_offset.should == 0 end it 'with a flat time, converts to UTC Time instance' do Time.parse_safely(@time_flat).should == @time_utc Time.parse_safely(@time_flat).utc_offset.should == 0 end it 'with a flat time and Z, converts to UTC Time instance' do Time.parse_safely(@time_flat+'Z').should == @time_utc Time.parse_safely(@time_flat+'Z').utc_offset.should == 0 end it 'parses a regular time string, converting to UTC' do Time.parse_safely(@time_iso_utc).should == @time_utc Time.parse_safely(@time_iso_utc).utc_offset.should == 0 Time.parse_safely(@time_iso_cst).should == @time_utc Time.parse_safely(@time_iso_cst).utc_offset.should == 0 end it 'round-trips' do Time.parse_safely(@time_flat).to_flat.should == @time_flat Time.parse_safely(@time_utc.to_flat).should == @time_utc end end end
Version data entries
7 entries across 7 versions & 1 rubygems