Skip to content

time: ParseInLocation may return time with a location that yields an empty string #71347

@aksdb

Description

@aksdb

Go version

1.23

Output of go env in your module/workspace:

[current playground]

What did you do?

I parse a time string using a known location name.
The resulting time ends up with the location name being empty, though.

	location, err := time.LoadLocation("Europe/Helsinki")
	if err != nil {
		panic(err)
	}
	t, err := time.ParseInLocation(time.RFC3339, "2022-09-29T13:00:00+02:00", location)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Expected: %s, Got: %s\n", location.String(), t.Location().String())

https://go.dev/play/p/WVdVLmBjkuL

What did you see happen?

The given example prints: Expected: Europe/Helsinki, Got:

What did you expect to see?

The given example prints: Expected: Europe/Helsinki, Got: Europe/Helsinki

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions