diff --git a/zapcore/encoder.go b/zapcore/encoder.go index 1bb684ae3..a1d46506f 100644 --- a/zapcore/encoder.go +++ b/zapcore/encoder.go @@ -107,7 +107,7 @@ func EpochNanosTimeEncoder(t time.Time, enc PrimitiveArrayEncoder) { // ISO8601TimeEncoder serializes a time.Time to an ISO8601-formatted string // with millisecond precision. func ISO8601TimeEncoder(t time.Time, enc PrimitiveArrayEncoder) { - enc.AppendString(t.Format("2006-01-02T15:04:05.999Z0700")) + enc.AppendString(t.Format("2006-01-02T15:04:05.000Z0700")) } // UnmarshalText unmarshals text to a TimeEncoder. "iso8601" and "ISO8601" are diff --git a/zapcore/encoder_test.go b/zapcore/encoder_test.go index 3f802d78c..d9af56688 100644 --- a/zapcore/encoder_test.go +++ b/zapcore/encoder_test.go @@ -403,17 +403,17 @@ func TestLevelEncoders(t *testing.T) { } func TestTimeEncoders(t *testing.T) { - moment := time.Unix(100, 5000500).UTC() + moment := time.Unix(100, 50005000).UTC() tests := []struct { name string expected interface{} // output of serializing moment }{ - {"iso8601", "1970-01-01T00:01:40.005Z"}, - {"ISO8601", "1970-01-01T00:01:40.005Z"}, - {"millis", 100005.0005}, - {"nanos", int64(100005000500)}, - {"", 100.0050005}, - {"something-random", 100.0050005}, + {"iso8601", "1970-01-01T00:01:40.050Z"}, + {"ISO8601", "1970-01-01T00:01:40.050Z"}, + {"millis", 100050.005}, + {"nanos", int64(100050005000)}, + {"", 100.050005}, + {"something-random", 100.050005}, } for _, tt := range tests {