Skip to content

Commit

Permalink
RecordFormatter: always use UTC
Browse files Browse the repository at this point in the history
This ensures consistent output .
  • Loading branch information
twmb committed Dec 7, 2021
1 parent 6ab9044 commit b8b7bd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/kgo/record_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (f *RecordFormatter) AppendPartitionRecord(b []byte, p *FetchPartition, r *
// An arbitrary amount of pounds, braces, and brackets are understood before
// beginning the actual timestamp formatting. For Go formatting, the format is
// simply passed to the time package's AppendFormat function. For strftime, all
// "man strftime" options are supported.
// "man strftime" options are supported. Time is always in UTC.
//
// Text
//
Expand Down Expand Up @@ -437,7 +437,7 @@ func NewRecordFormatter(layout string) (*RecordFormatter, error) {
}
layout = rem[1:]
f.fns = append(f.fns, func(b []byte, _ *FetchPartition, r *Record) []byte {
return writeR(b, r, func(b []byte, r *Record) []byte { return strftimeAppendFormat(b, tfmt, r.Timestamp) })
return writeR(b, r, func(b []byte, r *Record) []byte { return strftimeAppendFormat(b, tfmt, r.Timestamp.UTC()) })
})

case strings.HasPrefix(layout, "go"):
Expand All @@ -450,7 +450,7 @@ func NewRecordFormatter(layout string) (*RecordFormatter, error) {
}
layout = rem[1:]
f.fns = append(f.fns, func(b []byte, _ *FetchPartition, r *Record) []byte {
return writeR(b, r, func(b []byte, r *Record) []byte { return r.Timestamp.AppendFormat(b, tfmt) })
return writeR(b, r, func(b []byte, r *Record) []byte { return r.Timestamp.UTC().AppendFormat(b, tfmt) })
})

default:
Expand Down
2 changes: 1 addition & 1 deletion pkg/kgo/record_formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestRecordFormatter(t *testing.T) {

{
layout: "%d{strftime## %a ##} %d %d{ascii}",
expR: " Wed 17000 17000",
expR: " Thu 17000 17000",
},

{
Expand Down

0 comments on commit b8b7bd1

Please sign in to comment.