{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/9617","labels_url":"https://api.github.com/repos/golang/go/issues/9617/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/9617/comments","events_url":"https://api.github.com/repos/golang/go/issues/9617/events","html_url":"https://github.com/golang/go/issues/9617","id":54626178,"number":9617,"title":"time: parsing reference times seems to ignore three-letter timezones","user":{"login":"jovlinger","id":10566845,"avatar_url":"https://avatars.githubusercontent.com/u/10566845?v=3","gravatar_id":"","url":"https://api.github.com/users/jovlinger","html_url":"https://github.com/jovlinger","followers_url":"https://api.github.com/users/jovlinger/followers","following_url":"https://api.github.com/users/jovlinger/following{/other_user}","gists_url":"https://api.github.com/users/jovlinger/gists{/gist_id}","starred_url":"https://api.github.com/users/jovlinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jovlinger/subscriptions","organizations_url":"https://api.github.com/users/jovlinger/orgs","repos_url":"https://api.github.com/users/jovlinger/repos","events_url":"https://api.github.com/users/jovlinger/events{/privacy}","received_events_url":"https://api.github.com/users/jovlinger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-01-16T21:19:08Z","updated_at":"2015-02-23T03:18:08Z","closed_at":null,"body":"According to the docs for package time, the RFC822(Z) format of the reference time is\r\n\r\n        RFC822      = \"02 Jan 06 15:04 MST\"\r\n        RFC822Z     = \"02 Jan 06 15:04 -0700\"\r\n\r\nBut when I try to parse these times, the RFC822 one gets parsed as GMT rather than MST:\r\n\r\nrfc822 in RFC850 and unix seconds is Monday, 02-Jan-06 15:04:00 MST 1136214240\r\nrfc822z in RFC850 and unix seconds is Monday, 02-Jan-06 15:04:00 -0700 1136239440\r\nrfc822 == rfc822z: false\r\n\r\nfurthermore, once parsed, the result of Format into RFC850 doesn't conform to its own definition and can't be parsed into RFC850.\r\n\r\nhttp://play.golang.org/p/8q0OkLkNQ-\r\n\r\n(in case that link expires:)\r\n\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"time\"\r\n)\r\n\r\nfunc prt(name string, t time.Time) {\r\n\tfmt.Println(name, \"in RFC850 and unix seconds is\", t.Format(time.RFC850), t.Unix())\r\n}\r\n\r\nfunc main() {\r\n\trfc822, err1 := time.Parse(time.RFC822, time.RFC822)\r\n\trfc822z, err1z := time.Parse(time.RFC822Z, time.RFC822Z)\r\n\r\n\tif err1 != nil || err1z != nil {\r\n\t\tfmt.Println(err1)\r\n\t\tfmt.Println(err1z)\r\n\t\treturn\r\n\t}\r\n\tprt(\"rfc822\", rfc822)\r\n\tprt(\"rfc822z\", rfc822z)\r\n\tfmt.Println(\"rfc822 == rfc822z:\", rfc822.Equal(rfc822z))\r\n\r\n\trfc850, err850 := time.Parse(time.RFC850, rfc822z.Format(time.RFC850))\r\n\tif err850 != nil {\r\n\t\tfmt.Println(err850)\r\n\t\treturn\r\n\t}\r\n\tprt(\"rfc850\", rfc850)\r\n}"},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/75484445","html_url":"https://github.com/golang/go/issues/9617#issuecomment-75484445","issue_url":"https://api.github.com/repos/golang/go/issues/9617","id":75484445,"user":{"login":"blalor","id":109915,"avatar_url":"https://avatars.githubusercontent.com/u/109915?v=3","gravatar_id":"","url":"https://api.github.com/users/blalor","html_url":"https://github.com/blalor","followers_url":"https://api.github.com/users/blalor/followers","following_url":"https://api.github.com/users/blalor/following{/other_user}","gists_url":"https://api.github.com/users/blalor/gists{/gist_id}","starred_url":"https://api.github.com/users/blalor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blalor/subscriptions","organizations_url":"https://api.github.com/users/blalor/orgs","repos_url":"https://api.github.com/users/blalor/repos","events_url":"https://api.github.com/users/blalor/events{/privacy}","received_events_url":"https://api.github.com/users/blalor/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T03:18:08Z","updated_at":"2015-02-23T03:18:08Z","body":"It's broken and misleading.  If Go can't parse the timezone as provided in its own example format, it should throw an error.  This points out the inherent limitations of the example-driven format.  I think this problem wouldn't exist if Go supported token-based time parsing.\r\n\r\n[This example](http://play.golang.org/p/MWc0XNnIwd) shows that even though `time.Parse` sets the location to `PST`, the offset is broken:\r\n\r\n```\r\npackage main\r\n\r\nimport \"fmt\"\r\nimport \"time\"\r\n\r\nfunc main() {\r\n\tstr := \"Mon, 2 Jan 2006 15:04:05 MST\"\r\n\t// Mon Jan 2 15:04:05 MST 2006\r\n\tt, err := time.Parse(\"Mon, _2 Jan 2006 15:04:05 MST\", str)\r\n\tfmt.Printf(\"t: %v, err: %v\", t, err)\r\n}\r\n```\r\n\r\nThe output is\r\n```\r\nt: 2006-01-02 15:04:05 +0000 MST, err: <nil>\r\n```\r\n\r\nSo `time.Parse` can't even get its example timestamp correct.  This means there's a whole class of timestamps that Go can't parse (rss pubDates for example), despite defining those very formats as constants in the `time` package!"}}