diff --git a/operator/helper/time.go b/operator/helper/time.go index aa9ad876..2490b274 100644 --- a/operator/helper/time.go +++ b/operator/helper/time.go @@ -285,7 +285,7 @@ var subsecToNs = map[string]int64{"s.ms": 1e6, "s.us": 1e3, "s.ns": 1} // setTimestampYear sets the year of a timestamp to the current year. // This is needed because year is missing from some time formats, such as rfc3164. func setTimestampYear(t time.Time) time.Time { - if t.Year() > 1970 { + if t.Year() > 0 { return t } n := now() diff --git a/operator/helper/time_test.go b/operator/helper/time_test.go index 9837b4f9..2f7f6cbc 100644 --- a/operator/helper/time_test.go +++ b/operator/helper/time_test.go @@ -314,6 +314,13 @@ func TestTimeParser(t *testing.T) { strptimeLayout: "%Y-%m-%dT%H:%M:%S.%LZ", location: hst.String(), }, + { + name: "1970", + sample: "1970-12-16T21:43:28.391Z", + expected: time.Date(1970, 12, 16, 21, 43, 28, 391*1000*1000, time.UTC), + gotimeLayout: "2006-01-02T15:04:05.999Z", + strptimeLayout: "%Y-%m-%dT%H:%M:%S.%LZ", + }, } rootField := entry.NewBodyField()