diff options
author | Rob Pike <r@golang.org> | 2015-07-15 15:02:38 +1000 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2015-07-15 05:13:05 +0000 |
commit | 47f22ab77557b41c918894e004a78dc5952ea58a (patch) | |
tree | 2f2aaf99ec06f6946be29040239e9f6db23fcc9b | |
parent | d000e8742a173aa0659584aa01b7ba2834ba28ab (diff) | |
download | go-47f22ab77557b41c918894e004a78dc5952ea58a.tar.gz go-47f22ab77557b41c918894e004a78dc5952ea58a.zip |
time: make it clearer how to format a fractional second
Fixes #10963.
Change-Id: I8d769b4d25b306f2df41f882ec01d97bbd63171d
Reviewed-on: https://go-review.googlesource.com/12221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
-rw-r--r-- | src/time/format.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/time/format.go b/src/time/format.go index b15101e160..873d3ffde9 100644 --- a/src/time/format.go +++ b/src/time/format.go @@ -39,6 +39,9 @@ import "errors" // offset for the UTC zone. Thus: // Z0700 Z or ±hhmm // Z07:00 Z or ±hh:mm +// +// The executable example for time.Format demonstrates the working +// of the layout string in detail and is a good reference. const ( ANSIC = "Mon Jan _2 15:04:05 2006" UnixDate = "Mon Jan _2 15:04:05 MST 2006" @@ -405,6 +408,11 @@ func (t Time) String() string { // would be displayed if it were the value; it serves as an example of the // desired output. The same display rules will then be applied to the time // value. +// +// A fractional second is represented by adding a period and zeros +// to the end of the seconds section of layout string, as in "15:04:05.000" +// to format a time stamp with millisecond precision. +// // Predefined layouts ANSIC, UnixDate, RFC3339 and others describe standard // and convenient representations of the reference time. For more information // about the formats and the definition of the reference time, see the @@ -671,7 +679,7 @@ func skip(value, prefix string) (string, error) { // and convenient representations of the reference time. For more information // about the formats and the definition of the reference time, see the // documentation for ANSIC and the other constants defined by this package. -// Also, the executable Example for time.Format demonstrates the working +// Also, the executable example for time.Format demonstrates the working // of the layout string in detail and is a good reference. // // Elements omitted from the value are assumed to be zero or, when |