From 58c5be90990adde877bbf94d5af0c9cc0b48c6c7 Mon Sep 17 00:00:00 2001 From: Theo Willows Date: Tue, 21 Jan 2025 13:01:15 +0100 Subject: [PATCH] Fix bug in default time format --- handler.go | 2 +- handler_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/handler.go b/handler.go index c4c155b..9344af0 100644 --- a/handler.go +++ b/handler.go @@ -17,7 +17,7 @@ import ( const ( // DefaultTimeFormat is the default format for any [time.Time] logged. - DefaultTimeFormat = "2006-01-02T15:04:05,000Z07:00" + DefaultTimeFormat = "2006-01-02T15:04:05,999Z07:00" ) var ( diff --git a/handler_test.go b/handler_test.go index 3fe7db0..298dd69 100644 --- a/handler_test.go +++ b/handler_test.go @@ -42,7 +42,7 @@ func TestHandler(t *testing.T) { slog.Int("int", -123_456), slog.Int64("int64", 42), slog.String("string", "a string"), - slog.Time("time", time.Date(2000, 1, 2, 3, 4, 5, 6, time.UTC)), + slog.Time("time", time.Date(2000, 1, 2, 3, 4, 5, 6, time.UTC).Add(123_456*time.Microsecond)), slog.Uint64("uint64", 123456), }, Patterns: []string{ @@ -57,7 +57,7 @@ func TestHandler(t *testing.T) { `\sint=-123,456\b`, `\sline=\d+\b\b`, `\sstring=a string\b`, - `\stime=2000-01-02T03:04:05,000Z\b`, + `\stime=2000-01-02T03:04:05,123Z\b`, `\suint64=123,456\b`, }, },