3 ms·
So I copied the example from http://golang.org/pkg/time/#Parse http://golang.org/pkg/time/#Parse and it did NOT work as expected: http://play.golang.org/p/Xd9o
by paradite 11y ago
So I copied the example from http://golang.org/pkg/time/#Parse http://golang.org/pkg/time/#Parse
and it did NOT work as expected:
http://play.golang.org/p/Xd9oEeSffd http://play.golang.org/p/Xd9oEeSffd
(timezone offset is zero)
- nulltype 11y agoThis works correctly if your locale includes the PST timezone (works fine on my computer). They should probably have a better example though.
- paradite 11y agoBy "works fine" you mean in your local environment or the go playground? Because it could potentially cause problems if the execution result varies from geographical locations and user's environment. I for one have no idea if my computer has a locale that includes PST timezone.
- nulltype 11y agoSorry I meant in my local environment. It's clear that the execution varies, as Parse(), unlike ParseInLocation() depends on the local environment, and play.golang.org probably uses some UTC locale.
- teraflop 11y agoThat seems to be an issue with the playground: https://github.com/golang/go/issues/12388 https://github.com/golang/go/issues/12388 It seems counter-intuitive to me that the behavior of time.Parse would depend on a "system location", but apparently it's by design.
- mratzloff 11y agoTime is location-dependant (time zones).
- paradite 11y agoYou are missing the point. My point is that that particular datetime is parsed as 2013-02-03 19:54:00 +0000 PST on some machines, and 2013-02-03 19:54:00 -0800 PST on others. This is means that the timezone offset IS different and the absolute time IS different. One is 8 hours ahead of another even though the original string is the same.