Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time/tzdata: zoneinfo error for America/Tijuana #56913

Closed
JianyongGuo opened this issue Nov 23, 2022 · 8 comments
Closed

time/tzdata: zoneinfo error for America/Tijuana #56913

JianyongGuo opened this issue Nov 23, 2022 · 8 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@JianyongGuo
Copy link

JianyongGuo commented Nov 23, 2022

What did you do?

I found that the zoneinfo.zip data in latest golang versions is error (such go 1.18, go 1.19)

Because from tzdata 2022b, the zoneinfo generator zic has changed, and -R parameter is add.

-R parameter is using to generate redundant data until to 2038

How to reproduce the problem

step 1. run update.bash update zoneinfo.zip to 2022f

step 2.  run test code 
loc, _ = time.LoadLocation("America/Tijuana")
time_str := time.Now().In(loc).Format("2006-01-02 15:04:05")

step 3. check result
The result should be "2022-11-22 18:49:05"
But got "2022-11-22 19:49:05"

How to fix:

tzdata 2022f is released and the golang /lib/time/zoneinfo.zip need to be updated.
the update.bash script has some error, -R args is need for building zoneinfo data.

fix update.bash:

make CFLAGS=-DSTD_INSPIRED AWK=awk TOPDIR=output posix_only
shoule be:
make CFLAGS=-DSTD_INSPIRED AWK=awk TOPDIR=output   ZFLAGS='-R "@2137586400"'   posix_only
-R paramter is using to generate future DST rules.  
           Without -R parameter:  the zoneinfo data can only cover just NEXT year, e.g [1970, .... 2023]
           With -R:  Can generate all futher DST time, e.g  [1970, .... 2023,  2024,  2025, ... 2038]
@JianyongGuo JianyongGuo changed the title affected/package: affected/package: zoneinfo error for America/Tijuana Nov 23, 2022
@JianyongGuo JianyongGuo changed the title affected/package: zoneinfo error for America/Tijuana time error/go 1.19: zoneinfo error for America/Tijuana Nov 23, 2022
@JianyongGuo JianyongGuo changed the title time error/go 1.19: zoneinfo error for America/Tijuana timezone error/go 1.19: zoneinfo error for America/Tijuana Nov 23, 2022
@JianyongGuo JianyongGuo changed the title timezone error/go 1.19: zoneinfo error for America/Tijuana tzdata error/go 1.19: zoneinfo error for America/Tijuana Nov 23, 2022
@mengzhuo mengzhuo changed the title tzdata error/go 1.19: zoneinfo error for America/Tijuana time/tzdata: zoneinfo error for America/Tijuana Nov 23, 2022
@ianlancetaylor
Copy link
Contributor

I'm sorry, i can't recreate the problem.

I'm running this program:

package main

import (
	"fmt"
	"log"
	"time"
)

func main() {
	loc, err := time.LoadLocation("America/Tijuana")
	if err != nil {
		log.Fatal(err)
	}
	d := time.Date(2022, 11, 22, 10, 0, 0, 0, loc)
	fmt.Println(d)
}

It always prints 2022-11-22 10:00:00 -0800 PST regardless of how I run update.bash and set ZONEINFO.

Can you show complete and precise instructions for how to see the problem? Thanks.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 23, 2022
@JianyongGuo
Copy link
Author

You should test like this:
d := time.Now().In(loc).Format("2006-01-02 15:04:05")

When you trans a timestamp to string-style-time, it will has 1 hour diff with local real time

@JianyongGuo
Copy link
Author

Or you can test the code:

loc, _:= time.LoadLocation("America/Tijuana")
name, offset := time.Now().In(loc).Zone()
offset should be GMT-8 for "America/Tijuana", But go GMT-7

@randall77
Copy link
Contributor

I don't see the same thing you're seeing. The program:

package main

import (
	"fmt"
	"time"
)

func main() {
	loc, _ := time.LoadLocation("America/Tijuana")
	name, offset := time.Now().In(loc).Zone()
	fmt.Printf("%s %v\n", name, offset/3600)
}

Prints

PST -8

On both go1.18.8, go1.19.3, and tip (on darwin/amd64).

@ianlancetaylor
Copy link
Contributor

Please give us complete and precise instructions for how to see the problem. Tell us every single step. Be complete and precise. Thanks.

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Nov 23, 2022
@JianyongGuo
Copy link
Author

JianyongGuo commented Nov 24, 2022

step 1. run update.bash update zoneinfo.zip to 2022f

step 2. run test code
package main

import (
"fmt"
"time"
"os"
)

func main() {
os.Setenv("ZONEINFO", "/home/xxxx/zoneinfo.zip")
loc, _ := time.LoadLocation("America/Tijuana")
name, offset := time.Now().In(loc).Zone()
fmt.Printf("%s %v\n", name, offset/3600)
}

step 3. check result
offset should be GMT-8 for "America/Tijuana",
But go GMT-8 on Darwin/amd64 go 1.17
Got GMT-7 on Linux go 1.13
Got GMT-7 on Goland IDE go 1.13

@ianlancetaylor
Copy link
Contributor

Hmmm, are you really using Go 1.13? The fix for the problem you are describing was first released as part of the Go 1.14 release series (https://go.dev/cl/215539). Go 1.13 is no longer supported. The most recent release is Go 1.19. Can you recreate the problem using Go 1.19?

@JianyongGuo
Copy link
Author

I see, go 1.19 do not has this bug. If using go 1.13, -R option can solve this problem
We are coders of Chinese company , and we still using go 1.13 , haha!!

Thanks all you guys, this issue can closed.

@golang golang locked and limited conversation to collaborators Nov 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants