我一直在为调度界面设计一个UI,用户可以在未来的几个小时内设置计时器.如果可能的话,我希望能够处理夏令时,我认为这很简单.在检查golang包中的time.Time时,我遇到了以下不一致,如果是这样的话.
package main
import (
"fmt"
"time"
)
func main(){
const timeFormat = "2 Jan, 2006 3:04pm (MST)"
test , err := time.Parse( timeFormat, "25 Oct, 2015 1:59am (BST)" )
fmt.Println( test , test.UTC() , err)
dur , _ := time.ParseDuration( "1m" )
test = test.Add( dur )
fmt.Println( test , test.UTC())
fmt.Println( "--------------------" )
test , err = time.Parse( timeFormat, "25 Oct, 2015 2:01am (BST)" )
fmt.Println( test , test.UTC() , err)
test = test.Add( dur )
fmt.Println( test …Run Code Online (Sandbox Code Playgroud)