Hi

On Wed, Oct 08, 2014 at 12:23:59PM +0200, Markus Teich wrote:
> Heyho,
> 
> I am using a status bar script written in go[0]. Recently I have noticed two
> problems related to the time display, but first here is the relevant part of 
> the
> code:
> 
>       for clock := range time.Tick(time.Second) {
>               // …
>               clock.Format("Mon 02 15:04:05")
>               // …
>       }
> 
> Now the first problem occured when I was travelling to another timezone and
> updated my timezone information. Since clock only get's initialized once, we
> don't catch the new timezone info and the displayed time stays in the old
> timezone until the script is restarted.

I think you could use http://golang.org/pkg/time/#Time.Zone to
occasionally check wether the time zone has changed since the script has
been started and then use http://golang.org/pkg/time/#ParseInLocation to
output the time.


> The second problem is when using ntp to synchronize the clock. In this case 
> the
> channel provided by time.Tick() stops to send on that channel and therefore 
> the
> whole loop stops and the status bar is not updated anymore.

In this issue https://code.google.com/p/go/issues/detail?id=6007
in answer #30 they mention that they use a monotonic clock on Linux
now with Go 1.3 and up which should solve this (this is the commit
https://code.google.com/p/go/source/detail?r=79f855ac890d ). What platform
and Go version are you using?


Reply via email to