From d7816039314d46701e99e52d0e1485a158a5fc06 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Sun, 26 Feb 2012 22:24:51 +1100 Subject: [PATCH] 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 --- src/pkg/time/time.go | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- 2.48.1