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

Wrong timezone in Go #760

Closed
aral opened this Issue Jul 4, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@aral
Copy link

aral commented Jul 4, 2018

I'm running Hugo on my Nexus 5 via Termux (thank you, by the way, for this amazing contribution to humanity) and when I changed the datestamp on a post manually to the current time, I noticed that Hugo did not build my post because it thought the time was in the future. That's when I realised that it had written the date stamp with a timezone of Z while creating the post instead of +01:00 (I'm on Irish Standard Time at the moment).

Context

  • Time and timezone on the phone is set and displayed correctly
  • In a Termux session, date produces the right time and date and timezone (IST)
  • getprop persist.sys.timezone produces the correct timezone (Europe/Dublin)

To replicate

The following basic Go app produces the wrong timezone consistently for me both under plain Termux and under termux-chroot:

package main

import "time"
import "fmt"

func main() {
  p := fmt.Println
  t := time.Now()
  p(t.Format(time.RFC3339))
}

Sample output

date
Wed Jul  4 16:48:28 IST 2018

getprop persist.sys.timezone
Europe/Dublin

go run time.go
2018-07-04T15:48:37Z

So Go thinks its on UTC even though we're on IST.

Update

I’ve just verified on my Mac that this is erroneous behaviour in Termux and not an anomaly specific to Go. The output of the same script and the corresponding date results are in the screenshot below:

screen shot 2018-07-04 at 17 28 38

Update 2

As a further check, the issue does not exist in Node.js under a Termux session. The following code:

let t = new Date().toTimeString()
console.log(t)

Produces:

17:38:36 GMT +0100 (IST)

@aral aral changed the title Wrong timezone in Go Wrong timezone in Go and Node.js Jul 4, 2018

@aral aral changed the title Wrong timezone in Go and Node.js Wrong timezone in Go Jul 4, 2018

@fornwall

This comment has been minimized.

Copy link
Member

fornwall commented Jul 5, 2018

Thaknks for reporting! Seems to be hitting this issue: golang/go#20455

@fornwall

This comment has been minimized.

Copy link
Member

fornwall commented Jul 5, 2018

This issue was moved to termux/termux-packages#2622

@fornwall fornwall closed this Jul 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment