Skip to content

Commit e78ca33

Browse files
author
Jérôme Renard
committed
Fixed wrong timestamp format.
Ref : https://tools.ietf.org/html/rfc3164#section-4.1.2 : "If the day of the month is less than 10, then it MUST be represented as a space and then the number." Fixes #1 (hopefully for real this time)
1 parent 51aa7e5 commit e78ca33

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

rfc3164/rfc3164.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (p *Parser) parseTimestamp() (time.Time, error) {
129129

130130
tsFmts := []string{
131131
"Jan 02 15:04:05",
132-
"Jan 2 15:04:05",
132+
"Jan 2 15:04:05",
133133
}
134134

135135
found := false

rfc3164/rfc3164_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ var (
1818
_ = Suite(&Rfc3164TestSuite{})
1919

2020
// XXX : corresponds to the length of the last tried timestamp format
21-
// XXX : Jan 2 15:04:05
22-
lastTriedTimestampLen = 14
21+
// XXX : Jan 2 15:04:05
22+
lastTriedTimestampLen = 15
2323
)
2424

2525
func (s *Rfc3164TestSuite) TestParser_Valid(c *C) {
@@ -68,7 +68,7 @@ func (s *Rfc3164TestSuite) TestParseHeader_InvalidTimestamp(c *C) {
6868
buff := []byte("Oct 34 32:72:82 mymachine ")
6969
hdr := header{}
7070

71-
s.assertRfc3164Header(c, hdr, buff, lastTriedTimestampLen, syslogparser.ErrTimestampUnknownFormat)
71+
s.assertRfc3164Header(c, hdr, buff, lastTriedTimestampLen+1, syslogparser.ErrTimestampUnknownFormat)
7272
}
7373

7474
func (s *Rfc3164TestSuite) TestParsemessage_Valid(c *C) {
@@ -103,7 +103,7 @@ func (s *Rfc3164TestSuite) TestParseTimestamp_TrailingSpace(c *C) {
103103
func (s *Rfc3164TestSuite) TestParseTimestamp_OneDigitForMonths(c *C) {
104104
// XXX : no year specified. Assumed current year
105105
// XXX : no timezone specified. Assume UTC
106-
buff := []byte("Oct 1 22:14:15")
106+
buff := []byte("Oct 1 22:14:15")
107107

108108
now := time.Now()
109109
ts := time.Date(now.Year(), time.October, 1, 22, 14, 15, 0, time.UTC)

0 commit comments

Comments
 (0)