1
0
mirror of https://github.com/golang/go synced 2024-11-25 10:07:56 -07:00

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
This commit is contained in:
Rob Pike 2012-02-26 22:24:51 +11:00
parent f7ad1834ea
commit d781603931

View File

@ -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