Skip to content

log/slog: slog.Time, doesn't handle dates after year 2262 #65902

Closed
@mvrhov

Description

@mvrhov

Go version

1.21, 1.22

Output of go env in your module/workspace:

/

What did you do?

package main

import (
	"log/slog"
	"os"
	"time"
)

func main() {
	logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
	logger.Info("time test", slog.Time("expires_at", time.Date(2300, 1, 1, 0, 0, 0, 0, time.UTC)))
}

This is due to converting time.Time to nanosecond in slog.Time

What did you see happen?

{"time":"2009-11-10T23:00:00Z","level":"INFO","msg":"time test","expires_at":"1715-06-13T00:25:26.290448384Z"}

What did you expect to see?

I expected to see date in future e.g 2300-01-01 00:00:00.0Z in this case

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions