mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
fix parsing of datetimes with timezone (thanks sigi)
This commit is contained in:
parent
341a481231
commit
6265b2d804
@ -13,7 +13,7 @@ module ValidatesTimeliness
|
|||||||
if type == :date
|
if type == :date
|
||||||
Date.new(*time_array[0..2]) rescue nil
|
Date.new(*time_array[0..2]) rescue nil
|
||||||
else
|
else
|
||||||
make_time(time_array[0..7])
|
make_time(time_array[0..6])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,10 @@ describe ValidatesTimeliness::Parser do
|
|||||||
it "should return time object for valid time string" do
|
it "should return time object for valid time string" do
|
||||||
parse("2000-01-01 12:13:14", :datetime).should be_kind_of(Time)
|
parse("2000-01-01 12:13:14", :datetime).should be_kind_of(Time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return Time object for ISO 8601 string with time zone" do
|
||||||
|
parse("2000-01-01T12:23:42+09:00", :datetime).should be_kind_of(Time)
|
||||||
|
end
|
||||||
|
|
||||||
it "should return nil for time string with invalid date part" do
|
it "should return nil for time string with invalid date part" do
|
||||||
parse("2000-02-30 12:13:14", :datetime).should be_nil
|
parse("2000-02-30 12:13:14", :datetime).should be_nil
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user