mirror of
https://github.com/meineerde/rackstash.git
synced 2026-02-01 01:37:12 +00:00
Interpret a Date in the Gelf timestamp field as UTC midnight
This commit is contained in:
parent
a70b859a53
commit
a807f99af5
@ -134,8 +134,10 @@ module Rackstash
|
||||
|
||||
def gelf_timestamp(timestamp)
|
||||
time = case timestamp
|
||||
when Time, DateTime, Date
|
||||
when Time, DateTime
|
||||
timestamp.to_time
|
||||
when Date
|
||||
Time.new(timestamp.year, timestamp.month, timestamp.day, 0, 0, 0, 0)
|
||||
when String
|
||||
Time.iso8601(timestamp) rescue Time.now.utc
|
||||
when Integer, Float
|
||||
|
||||
@ -55,7 +55,7 @@ RSpec.describe Rackstash::Encoder::GELF do
|
||||
|
||||
it 'formats a Date' do
|
||||
event = { '@timestamp' => Date.new(2016, 10, 17) }
|
||||
expect(encoder.encode(event)).to include '"timestamp":1476655200.0'
|
||||
expect(encoder.encode(event)).to include '"timestamp":1476662400.0'
|
||||
end
|
||||
|
||||
it 'formats a String' do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user