Skip to content

Commit

Permalink
fix parsing of noncompliant RFC3339 timestamps missing only a timezone (
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbsgilbs authored Jan 30, 2025
1 parent 172d6c6 commit 5260cf1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/parser/enrich_date.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func GenDateParse(date string) (string, time.Time) {
"2006-01-02 15:04",
"2006/01/02 15:04:05",
"2006-01-02 15:04:05",
"2006-01-02T15:04:05",
}
)

Expand Down
32 changes: 32 additions & 0 deletions pkg/parser/enrich_date_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,38 @@ func TestDateParse(t *testing.T) {
},
expected: "2011-12-17T08:17:43Z",
},
{
name: "ISO 8601, no timezone",
evt: types.Event{
StrTime: "2024-11-26T20:13:32",
StrTimeFormat: "",
},
expected: "2024-11-26T20:13:32Z",
},
{
name: "ISO 8601, no timezone, milliseconds",
evt: types.Event{
StrTime: "2024-11-26T20:13:32.123",
StrTimeFormat: "",
},
expected: "2024-11-26T20:13:32.123Z",
},
{
name: "ISO 8601, no timezone, microseconds",
evt: types.Event{
StrTime: "2024-11-26T20:13:32.123456",
StrTimeFormat: "",
},
expected: "2024-11-26T20:13:32.123456Z",
},
{
name: "ISO 8601, no timezone, nanoseconds",
evt: types.Event{
StrTime: "2024-11-26T20:13:32.123456789",
StrTimeFormat: "",
},
expected: "2024-11-26T20:13:32.123456789Z",
},
}

logger := log.WithField("test", "test")
Expand Down

0 comments on commit 5260cf1

Please sign in to comment.