mirror of
https://github.com/golang/go
synced 2024-11-22 04:54:42 -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:
parent
f7ad1834ea
commit
d781603931
@ -384,6 +384,15 @@ type Duration int64
|
|||||||
|
|
||||||
// Common durations. There is no definition for units of Day or larger
|
// Common durations. There is no definition for units of Day or larger
|
||||||
// to avoid confusion across daylight savings time zone transitions.
|
// 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 (
|
const (
|
||||||
Nanosecond Duration = 1
|
Nanosecond Duration = 1
|
||||||
Microsecond = 1000 * Nanosecond
|
Microsecond = 1000 * Nanosecond
|
||||||
|
Loading…
Reference in New Issue
Block a user