From: Rob Pike Date: Sun, 26 Feb 2012 11:24:51 +0000 (+1100) Subject: time: add a comment about how to use the Duration constants X-Git-Tag: weekly.2012-03-04~149 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d7816039314d46701e99e52d0e1485a158a5fc06;p=gostls13.git time: add a comment about how to use the Duration constants R=golang-dev, bradfitz, r, dsymonds CC=golang-dev https://golang.org/cl/5696078 --- diff --git a/src/pkg/time/time.go b/src/pkg/time/time.go index 709a422672..1b8c76fcc4 100644 --- a/src/pkg/time/time.go +++ b/src/pkg/time/time.go @@ -384,6 +384,15 @@ type Duration int64 // Common durations. There is no definition for units of Day or larger // to avoid confusion across daylight savings time zone transitions. +// +// To count the number of units in a Duration, divide: +// second := time.Second +// fmt.Print(int64(second/time.Millisecond)) // prints 1000 +// +// To convert an integer number of units to a Duration, multiply: +// seconds := 10 +// fmt.Print(time.Duration(seconds)*time.Second) // prints 10s +// const ( Nanosecond Duration = 1 Microsecond = 1000 * Nanosecond