Sha256: de9266958ab2990e1bd36db346a8e1e03ec229f82b46fc5da767788b96d73caa
Contents?: true
Size: 1.62 KB
Versions: 3
Compression:
Stored size: 1.62 KB
Contents
require File.expand_path('../spec_helper', File.dirname(__FILE__)) require 'gorillib/datetime/flat' require 'gorillib/datetime/parse' describe DateTime 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gorillib-0.1.11 | spec/datetime/parse_spec.rb |
gorillib-0.1.9 | spec/datetime/parse_spec.rb |
gorillib-0.1.8 | spec/datetime/parse_spec.rb |