diff --git a/lib/savon/core_ext/time.rb b/lib/savon/core_ext/time.rb index 36d6674b..55aa99d9 100644 --- a/lib/savon/core_ext/time.rb +++ b/lib/savon/core_ext/time.rb @@ -4,7 +4,15 @@ module Time # Returns an xs:dateTime formatted String. def xs_datetime - strftime "%Y-%m-%dT%H:%M:%S%Z" + zone = if utc_offset < 0 + "-#{"%02d" % (- utc_offset / 3600)}:#{"%02d" % ((- utc_offset % 3600) / 60)}" + elsif utc_offset > 0 + "+#{"%02d" % (utc_offset / 3600)}:#{"%02d" % ((utc_offset % 3600) / 60)}" + else + "Z" + end + + strftime "%Y-%m-%dT%H:%M:%S#{zone}" end end diff --git a/spec/savon/core_ext/time_spec.rb b/spec/savon/core_ext/time_spec.rb index 92676617..9e8ebcda 100644 --- a/spec/savon/core_ext/time_spec.rb +++ b/spec/savon/core_ext/time_spec.rb @@ -6,7 +6,7 @@ let(:time) { Time.utc(2011, 01, 04, 13, 45, 55) } it "should return an xs:dateTime formatted String" do - time.xs_datetime.should == "2011-01-04T13:45:55UTC" + time.xs_datetime.should == "2011-01-04T13:45:55Z" end end