Skip to content

time: ParseInLocation incorrect after 2038 #25343

@jimcheetham

Description

@jimcheetham

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.10.2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

using https://play.golang.org

What did you do?

Used time.ParseInLocation to grok a time from "Europe/London"

Noticed that the resulting time switched from BST (appropriate for the month/day used) to GMT after 2038

package main

import "fmt"
import "time"

func main() {

	var timet = "2037-05-06 00:54:39"
	var timef = "2038-05-06 00:54:39"

	tz, _ := time.LoadLocation("Europe/London")

	tinz, _ := time.ParseInLocation("2006-01-02 15:04:05", timet, tz)
	finz, _ := time.ParseInLocation("2006-01-02 15:04:05", timef, tz)

	fmt.Printf("TimeT: %v\nTimeF: %v\n", tinz, finz)
	
}

https://play.golang.org/p/5oMrjFT_3F1

What did you expect to see?

TimeT: 2037-05-06 00:54:39 +0100 BST
TimeF: 2038-05-06 00:54:39 +0100 BST

The 2038 date as BST, the same as the 2037 date. See this example of GNU coreutils 8.26 date() :

$ TZ="Europe/London" date -d '2018-05-06 00:54:39'
Sun May  6 00:54:39 BST 2018
$ TZ="Europe/London" date -d '3304-05-06 00:54:39'
Tue May  6 00:54:39 BST 3304

What did you see instead?

TimeT: 2037-05-06 00:54:39 +0100 BST
TimeF: 2038-05-06 00:54:39 +0000 GMT

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions