Sunday, 15 April 2012

go - Daylight saving hours in Golang -


I am preparing a UI for a scheduling interface, where a user can set the timer several hours in the future . If possible, I want to be able to handle Daylight Savings, I thought it would be quite easy. While checking time, I went to the following inconsistency in the Golang package, if it is that which is.

  Package main import ("fmt" "time") func main () {Fairy timeformat = "January 2, 2006 3:04 pm (MST)" test, mistake : Time =. Purse (time format, "25th October, 1:59 am (bst)") fmt.println (test, test.itc), err) dur, _: = time.ParseDuration ("1m") test = test.Add ( Dur) fmt.println (test, test.UTC ()) fmt.Println ("--------- -----------") test, err = time.Parse (time format , "October 25, 2015 2:01 AM (BST)") fmt.println (test, test.UTC (), mistake) test = test.Add (dur) fmt.println (test, test.UTC ()) test = Test.Sub (dur) fmt.println (test, test.UTC ())}  

I know that on October 25, 2015, at 2 pm on BST at 1:00 GMT ( UTC) should go back. If I increase BST between 1 minute to 1:59 then actually the time is switched to GMT.

  2015-10-25 01:59:00 +0100 BST 2015-10-25 00:59: 00 0000 UTC & lt; Zero & gt; 2015-10-25 01:00:00 +0000 GMT 2015-10-25 01:00:00 +0000 UTC -------------------- 2015-10- 25 02:01:00 +0000 BST 2015-10-25 02:01:00 +0000 UTC & lt; Zero & gt; 2015-10-25 02:02:00 +0000 BST 2015-10-25 02:02:00 +0000 UTC  

However if I had a time of 2:00 in BST If I analyze, I hope it will be to switch to GMT, as the time of transition has to be increased. If the transitional code was called by Ad, then I add a minute again, but this time does not even return to GMT.

b) Always be GMT + 1

b) for BST

a) BST "invalid" at the right time GMT time (right) Invalid BST is between 2:00 on October 2 after the last Sunday in October and the last Sunday of the following Sunday in March)

c) An error if a date was created with those dates with BST (And possibly other daylight saving hours in other countries).

Otherwise, I would have to check whether a user enters a date in BST or not that the date is outside of BST and adjust or emphasize users at UTC time, which is built in the library. Deals the object with the daylight saving function.

During the research I saw it and I have decided that it is definitely not as easy as I previously believed ...

To handle daylight saving time There will be no insight or better way for

Edited Version: Version 1.3.3 was retried and this output was received

  2015- 10-25 01:59 : 00 + 10100 BST 2015-10-25 00:59:00 +0000 UTC < Zero & gt; 2015-10-25 01:00:00 +0000 GMT 2015-10-25 01:00:00 +0000 UTC -------------------- 2015-10- 25 01:00:00 +0000 GMT 2015-10-25 01:00:00 +0000 UTC & lt; Zero & gt; 2015-10-25 01:01:00 +0000 GMT 2015-10-25 01:01:00 +0000 UTC  

It looks as if I used to expect later versions. .. If this question has also been received then it will be fully read.

Thank you.

Go, like everyone else but Microsoft, regularly updates that are included in the current go release uses it.

You used .1.0.3 which was released in March 2012. British time zone data for 2015 added later

Always use a current version of Go for Time Zone Count


No comments:

Post a Comment