1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Do not mutate external time objects when getting UTC time

This commit is contained in:
Holger Just 2017-07-19 13:37:38 +02:00
parent b573581a26
commit 7032cc6999
3 changed files with 3 additions and 3 deletions

View File

@ -217,7 +217,7 @@ module Rackstash
def timestamp(time = nil)
@timestamp ||= begin
time ||= Time.now
time.utc.iso8601(ISO8601_PRECISION).freeze
time.getutc.iso8601(ISO8601_PRECISION).freeze
end
end
end

View File

@ -149,7 +149,7 @@ module Rackstash
end
return array
when ::Time
return value.utc.iso8601(ISO8601_PRECISION).freeze
return value.getutc.iso8601(ISO8601_PRECISION).freeze
when ::DateTime
return value.to_time.utc.iso8601(ISO8601_PRECISION).freeze
when ::Date

View File

@ -304,7 +304,7 @@ describe Rackstash::Buffer do
now = Time.parse('2016-10-17 13:37:00 +03:00')
expect(Time).to receive(:now).once.and_return(now)
expect(now).to receive(:utc).once.and_return(now.utc)
expect(now).to receive(:getutc).once.and_return(now.getutc)
expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000Z'
expect(buffer.timestamp).to eql '2016-10-17T10:37:00.000Z'