From b8b7bd1ea3b34a1a904fbf48b72f5273ec066eb6 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Mon, 6 Dec 2021 21:06:37 -0700 Subject: [PATCH] RecordFormatter: always use UTC This ensures consistent output . --- pkg/kgo/record_formatter.go | 6 +++--- pkg/kgo/record_formatter_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/kgo/record_formatter.go b/pkg/kgo/record_formatter.go index 2b1d2160..8684ef1c 100644 --- a/pkg/kgo/record_formatter.go +++ b/pkg/kgo/record_formatter.go @@ -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 // @@ -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"): @@ -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: diff --git a/pkg/kgo/record_formatter_test.go b/pkg/kgo/record_formatter_test.go index 37091f71..5e60c108 100644 --- a/pkg/kgo/record_formatter_test.go +++ b/pkg/kgo/record_formatter_test.go @@ -53,7 +53,7 @@ func TestRecordFormatter(t *testing.T) { { layout: "%d{strftime## %a ##} %d %d{ascii}", - expR: " Wed 17000 17000", + expR: " Thu 17000 17000", }, {