Weird timezone (+139 TMT). Is it Go-specific issue?

369 views
Skip to first unread message

Ivan Daniluk

unread,
Feb 27, 2015, 7:43:24 PM2/27/15
to golan...@googlegroups.com
Hi all,

I'm in Tallinn (Estonia) right now (EET) and the next code produces strange result for me, both on Linux GAE-instance, and on local MacOS X:
package main

import (
"fmt"
"time"
)

func main() {
tzName, tzOffset := time.Now().In(time.Local).Zone()
fmt.Printf("time.Local is: %s (GMT+%d)\n", tzName, tzOffset/3600)

t, _ := time.Parse("15:04", "14:35")
fmt.Println("T:", t)
fmt.Println("T:", t.In(time.Local))

fmt.Println("Now:", time.Now().In(time.Local))
}


Output:
time.Local is: EET (GMT+2)
T: 0000-01-01 14:35:00 +0000 UTC
T: 0000-01-01 16:14:00 +0139 TMT
Now: 2015-02-28 02:41:02.452292128 +0200 EET

Notice that "+0139 TMT" zone. It appears only with time obtained by time.Parse(). With time.Now() it seems to be ok.

I can't find any information on that weird timezone. Can someone clarify this?
Looks like bug for me.

Ian Lance Taylor

unread,
Feb 27, 2015, 8:13:21 PM2/27/15
to Ivan Daniluk, golang-nuts
Note that it might be more informative if you printed out tzOffset
before dividing by 3600, since that will drop out the odd minutes
offset.

Based on looking at the zoneinfo data, I think this is correct. Note
that your parsed time has no date. It is in the year zero. The
zoneinfo data for Tallinn says

Zone Europe/Tallinn 1:39:00 - LMT 1880
1:39:00 - TMT 1918 Feb # Tallinn Mean Time
1:00 C-Eur CE%sT 1919 Jul
1:39:00 - TMT 1921 May
2:00 - EET 1940 Aug 6
3:00 - MSK 1941 Sep 15
1:00 C-Eur CE%sT 1944 Sep 22
3:00 Russia MSK/MSD 1989 Mar 26 2:00s
2:00 1:00 EEST 1989 Sep 24 2:00s
2:00 C-Eur EE%sT 1998 Sep 22
2:00 EU EE%sT 1999 Nov 1
2:00 - EET 2002 Feb 21
2:00 EU EE%sT

In other words, before 1918, Tallinn apparently really was at an
offset of 1:39 from GMT. Since you are asking for the timezone in the
year zero, which is before 1918, you get the unusual offset.

So I think the result is surprising but technically correct.

Ian

Ian Lance Taylor

unread,
Feb 27, 2015, 8:13:58 PM2/27/15
to Ivan Daniluk, golang-nuts
On Fri, Feb 27, 2015 at 4:43 PM, Ivan Daniluk <ivan.d...@gmail.com> wrote:
>

Ivan Daniluk

unread,
Feb 28, 2015, 3:04:21 AM2/28/15
to golan...@googlegroups.com, ivan.d...@gmail.com
Thanks Ian, that's make sense now.

It was the case, where I used time.Time for storing only time information, ignoring the date.
Reply all
Reply to author
Forward
0 new messages