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: timezone name heuristic in Parse rejects MSK and MSD #3790
Labels
Milestone
Comments
Here's results: AZOST CHADT CHAST ChST EASST GMT-1 GMT+1 GMT-10 GMT+10 GMT-11 GMT+11 GMT-12 GMT+12 GMT-13 GMT-14 GMT-2 GMT+2 GMT-3 GMT+3 GMT-4 GMT+4 GMT-5 GMT+5 GMT-6 GMT+6 GMT-7 GMT+7 GMT-8 GMT+8 GMT-9 GMT+9 MeST MSK UTC WARST zzz The script I've used and raw results: https://gist.github.com/4250471 |
The same, but I've included historical timezones for 1850 -- 2012 years AKTST ALMST ANAST AQTST ASHST AZOMT AZOST BAKST BEAUT BORTST CHADT CHAST CHOST ChST CKHST DUSST EASST FRUST GMT-1 GMT+1 GMT-10 GMT+10 GMT-11 GMT+11 GMT-12 GMT+12 GMT-13 GMT-14 GMT-2 GMT+2 GMT-3 GMT+3 GMT-4 GMT+4 GMT-5 GMT+5 GMT-6 GMT+6 GMT-7 GMT+7 GMT-8 GMT+8 GMT-9 GMT+9 HOVST IRKST KIZST KRAST KUYST MADMT MADST MAGST MALST MeST MSD MSK NOVST OMSST ORAST PETST QYZST SAKST SAMST SHEST SVEST TASST TBIST ULAST URAST UTC UYHST VLASST VLAST VOLST WARST YAKST YEKST YERST zzz Updated script and raw results: https://gist.github.com/4251094 |
Windows uses UTC[+-][0-9]+ sometimes. Perhaps we should allow those in addition to GMT[+-][0-9]+. See notes on issue #4838. |
Issue #5672 has been merged into this issue. |
I found one more: MST --- FAIL: TestLocalZoneAbbr (0.00 seconds) zoneinfo_windows_test.go:18: Parse failed: parsing time "Sat, 22 Jun 2013 13:42:36 +0200" as "Mon, 02 Jan 2006 15:04:05 MST": cannot parse "+0200" as "MST" Windows 7 x32 go version devel +56909cb770fe Fri Jun 21 18:07:57 2013 -0700 windows/386 Best regards, Dobrosław Żybort |
matrixik, Do you mind running this program http://play.golang.org/p/vCsioBDpMk on your computer and reporting results back here? I suspect your syscall.Timezoneinformation is different from what Go supports at this moment. And I am wonering why and what to do about it. Thank you. Alex |
Alex, Results: ``` i=syscall.Timezoneinformation{Bias:-60, StandardName:[32]uint16{0x15a, 0x72, 0x6f, 0x64, 0x6b, 0x6f, 0x77, 0x6f, 0x65, 0x75, 0x72, 0x6f, 0x70, 0x65, 0x6a, 0x73, 0x6b, 0x69, 0x20, 0x63, 0x7a, 0x61, 0x73, 0x20, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x2e, 0x0, 0x0}, StandardDate:syscall.Systemtime{Year:0x0, Month:0xa, DayOfWeek:0x0, Day:0x5, Hour:0x3, Minute:0x0, Second:0x0, Milliseconds:0x0}, StandardBias:0, DaylightName:[32]uint16{0x15a, 0x72, 0x6f, 0x64, 0x6b, 0x6f, 0x77, 0x6f, 0x65, 0x75, 0x72, 0x6f, 0x70, 0x65, 0x6a, 0x73, 0x6b, 0x69, 0x20, 0x63, 0x7a, 0x61, 0x73, 0x20, 0x6c, 0x65, 0x74, 0x6e, 0x69, 0x0, 0x0, 0x0}, DaylightDate:syscall.Systemtime{Year:0x0, Month:0x3, DayOfWeek:0x0, Day:0x5, Hour:0x2, Minute:0x0, Second:0x0, Milliseconds:0x0}, DaylightBias:-60} i.StandardName="Środkowoeuropejski czas stand." i.DaylightName="Środkowoeuropejski czas letni" ``` Where: Środkowoeuropejski czas stand. = Central European Standard Time. Środkowoeuropejski czas letni = Central European Summer Time Best regards, Dobrosław Żybort |
matrixik, Thank you for the report. I think your issue is different, so I am starting new issue https://golang.org/issue/5783. Lets continue our conversation there. Alex |
Owner changed to @robpike. |
Is there a CL for this issue? What about something like this? diff -r da11b2a1cbc1 src/pkg/time/format.go --- a/src/pkg/time/format.go Tue Aug 06 12:04:08 2013 -0700 +++ b/src/pkg/time/format.go Wed Aug 07 01:18:31 2013 +0400 @@ -939,8 +939,17 @@ } else if len(value) >= 4 && value[3] == 'T' { p, value = value[0:4], value[4:] } else { - err = errBad - break + var i int + for i = 0; i < len(value); i++ { + if value[i] < 'A' || 'Z' < value[i] { + break + } + } + if i != 3 && i != 4 { + err = errBad + break + } + p, value = value[0:i], value[i:] } for i := 0; i < len(p); i++ { if p[i] < 'A' || 'Z' < p[i] { Making any 3 or 4 uppercase letters a timezone. |
On the other hand it might not be enough. This shows: http://www.timeanddate.com/library/abbreviations/timezones/ That timezones may be as short as 1 character, and there's one timezone with a lowercase letter in it: ChST. |
The full list at http://www.timeanddate.com/library/abbreviations/timezones/ shows that the [DMSU] check is wrong. there are many time zones that don't have that property, PWT for one. Thank you QuickCheck. |
If you need to scrape that page, this program: -------- package main import ( "fmt" "log" "net/http" "code.google.com/p/go.net/html" ) func walk(root *html.Node, f func(*html.Node)) { f(root) for n := root.FirstChild; n != nil; n = n.NextSibling { walk(n, f) } } func main() { res, err := http.Get("http://www.timeanddate.com/library/abbreviations/timezones/") if err != nil { log.Fatal(err) } defer res.Body.Close() doc, err := html.Parse(res.Body) if err != nil { log.Fatal(err) } walk(doc, func(n *html.Node) { if n.Type != html.ElementNode || n.Data != "tr" { return } n = n.FirstChild if n == nil || n.Type != html.ElementNode || n.Data != "td" { return } n = n.FirstChild if n == nil || n.Type != html.ElementNode || n.Data != "a" { return } n = n.FirstChild if n == nil || n.Type != html.TextNode { return } fmt.Println(n.Data) }) } -------- prints: -------- A ACDT ACST ADT ADT AEDT AEST AFT ... YAPT YEKST YEKT Z -------- Note that some rows (e.g. ADT) are repeated. |
This issue was updated by revision 727b2b6. Handle time zones like GMT-8. The more general time zone-matching problem is not yet resolved. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/12922043 |
Much to my disappointment, that URL doesn't have all the three-letter abbreviations even listed on my own machine. I think it's hopeless to have a definitive list, especially as it's sure to change as local governments decide to feel important by inventing their own time zones (I'm looking at you, Eucla). So it's sad but the right answer is probably just some simple sanity checks. CL coming. |
This issue was closed by revision a454d2f. Status changed to Fixed. |
diogomfranco, please run this program http://play.golang.org/p/vCsioBDpMk on your computer and post results here, so we know what your time zone is. Thank you. Alex |
This issue was closed by revision 4c855f3. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by k.shutemov:
The text was updated successfully, but these errors were encountered: