You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can see and understand why the final equality test returns false, but at the same time given that the default timezone is Z, would nevertheless expect the result to be true.
The text was updated successfully, but these errors were encountered:
I think you are missing my point. The time.Time documentation specifically says:
The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC.
therefore one would reasonably expect a zero-value time.Time (as constructed by time.Time{}) to compare equal to the one in which the timezone is explicitly UTC rather than nil.
Note that the Go == operator compares not just the time instant but also the Location. Therefore, Time values should not be used as map or database keys without first guaranteeing that the identical Location has been set for all values, which can be achieved through use of the UTC or Local method.
and
Two times can be equal even if they are in different locations. For example, 6:00 +0200 CEST and 4:00 UTC are Equal. This comparison is different from using t == u, which also compares the locations.
mikioh
changed the title
Zero value of time.Time does not remain equal under JSON marshal/unmarshal
time: Zero value of time.Time does not remain equal under JSON marshal/unmarshal
Aug 13, 2015
Please see:
http://play.golang.org/p/VXUScwoGAH
I can see and understand why the final equality test returns false, but at the same time given that the default timezone is Z, would nevertheless expect the result to be true.
The text was updated successfully, but these errors were encountered: