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: offset is getting repeated twice when date is parsed. #22664

Closed
saleem-mirza opened this issue Nov 10, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@saleem-mirza
Copy link

commented Nov 10, 2017

Please answer these questions before submitting your issue. Thanks!

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

go1.9.2 windows/amd64

Does this issue reproduce with the latest release?

yes

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

Windows/amd64

What did you do?

Parsed date with time offset. Please see link below.

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

https://play.golang.org/p/dhwzR4Y_LL

What did you expect to see?

Expected output is as below
2016-09-11 18:35:00 +0500

but see time offset is repeating twice.

What did you see instead?

2016-09-11 18:35:00 +0500 +0500

@gbbr gbbr changed the title Time offset is getting repeated twice when date is parsed. time: offset is getting repeated twice when date is parsed. Nov 10, 2017

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Nov 10, 2017

This is working as expected. When you print a time.Time value without formatting, it displays both the timezone offset and the timezone name. In your case the timezone has no name, so the time package is using the offset as the name.

If you want a different format, use the Format method.

Closing because there is nothing to do.

@gondo

This comment has been minimized.

Copy link

commented Jan 15, 2018

@ianlancetaylor problem is when I am trying to compare 2 times:
1st from database: "2008-01-03 00:00:00 +0100 CET"
2nd from unmarshall: "2008-01-03 00:00:00 +0100 +0100"
those 2 times are the same, but when I compare it, go says they are different

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jan 15, 2018

@gondo This issue is closed. For questions about using Go, use a forum; see https://golang.org/wiki/Questions . Thanks.

To compare two time values, use time.Equals.

@golang golang locked and limited conversation to collaborators Jan 15, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.