1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:54:40 -07:00

time: use "2006-01-02 15:04:05.999999999 -0700 MST" as String format

This change shows all the information present
in the Time value (now including fractional seconds)
and also arranges the fields so that, within a single time zone,
string comparison and time comparison agree.

R=golang-dev, rogpeppe, r
CC=golang-dev
https://golang.org/cl/5654078
This commit is contained in:
Russ Cox 2012-02-14 11:17:48 -05:00
parent c2e58dc568
commit d599accafa
2 changed files with 3 additions and 3 deletions

View File

@ -51,7 +51,7 @@ func ExampleMonth() {
}
}
// Go launched at Tue Nov 10 15:00:00 -0800 PST 2009
// Go launched at 2009-11-10 15:00:00 -0800 PST
func ExampleDate() {
t := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
fmt.Printf("Go launched at %s\n", t.Local())

View File

@ -344,9 +344,9 @@ func formatNano(nanosec, n int, trim bool) string {
}
// String returns the time formatted using the format string
// "Mon Jan _2 15:04:05 -0700 MST 2006"
// "2006-01-02 15:04:05.999999999 -0700 MST"
func (t Time) String() string {
return t.Format("Mon Jan _2 15:04:05 -0700 MST 2006")
return t.Format("2006-01-02 15:04:05.999999999 -0700 MST")
}
type buffer []byte