Hacker News new | past | comments | ask | show | jobs | submit login

So I copied the example from http://golang.org/pkg/time/#Parse

and it did NOT work as expected: http://play.golang.org/p/Xd9oEeSffd

(timezone offset is zero)




That seems to be an issue with the playground: 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.


Time is location-dependant (time zones).


You 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.


This works correctly if your locale includes the PST timezone (works fine on my computer). They should probably have a better example though.


By "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.


Sorry 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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: