mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:06:41 +08:00
Add中week增加类型转换 (#554)
cannot use week (type float64) as type time.Duration in argument to t.Add
This commit is contained in:
@@ -40,7 +40,7 @@ func main() {
|
||||
fmt.Println(time.Now()) // Wed Dec 21 09:52:14 +0100 RST 2011
|
||||
// calculating times:
|
||||
week = 60 * 60 * 24 * 7 * 1e9 // must be in nanosec
|
||||
week_from_now := t.Add(week)
|
||||
week_from_now := t.Add(time.Duration(week))
|
||||
fmt.Println(week_from_now) // Wed Dec 28 08:52:14 +0000 UTC 2011
|
||||
// formatting times:
|
||||
fmt.Println(t.Format(time.RFC822)) // 21 Dec 11 0852 UTC
|
||||
|
Reference in New Issue
Block a user