mirror of https://github.com/golang/go.git
time: add DateTime, DateOnly, and TimeOnly
Add named constants for the 3rd, 4th, and 13th most popular formats. Fixes #52746 Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c Reviewed-on: https://go-review.googlesource.com/c/go/+/412495 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
This commit is contained in:
parent
662a729ded
commit
0981d9fff1
|
|
@ -0,0 +1,6 @@
|
||||||
|
pkg time, const DateOnly = "2006-01-02" #52746
|
||||||
|
pkg time, const DateOnly ideal-string #52746
|
||||||
|
pkg time, const DateTime = "2006-01-02 15:04:05" #52746
|
||||||
|
pkg time, const DateTime ideal-string #52746
|
||||||
|
pkg time, const TimeOnly = "15:04:05" #52746
|
||||||
|
pkg time, const TimeOnly ideal-string #52746
|
||||||
|
|
@ -116,6 +116,9 @@ const (
|
||||||
StampMilli = "Jan _2 15:04:05.000"
|
StampMilli = "Jan _2 15:04:05.000"
|
||||||
StampMicro = "Jan _2 15:04:05.000000"
|
StampMicro = "Jan _2 15:04:05.000000"
|
||||||
StampNano = "Jan _2 15:04:05.000000000"
|
StampNano = "Jan _2 15:04:05.000000000"
|
||||||
|
DateTime = "2006-01-02 15:04:05"
|
||||||
|
DateOnly = "2006-01-02"
|
||||||
|
TimeOnly = "15:04:05"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,9 @@ var formatTests = []FormatTest{
|
||||||
{"StampMilli", StampMilli, "Feb 4 21:00:57.012"},
|
{"StampMilli", StampMilli, "Feb 4 21:00:57.012"},
|
||||||
{"StampMicro", StampMicro, "Feb 4 21:00:57.012345"},
|
{"StampMicro", StampMicro, "Feb 4 21:00:57.012345"},
|
||||||
{"StampNano", StampNano, "Feb 4 21:00:57.012345600"},
|
{"StampNano", StampNano, "Feb 4 21:00:57.012345600"},
|
||||||
|
{"DateTime", DateTime, "2009-02-04 21:00:57"},
|
||||||
|
{"DateOnly", DateOnly, "2009-02-04"},
|
||||||
|
{"TimeOnly", TimeOnly, "21:00:57"},
|
||||||
{"YearDay", "Jan 2 002 __2 2", "Feb 4 035 35 4"},
|
{"YearDay", "Jan 2 002 __2 2", "Feb 4 035 35 4"},
|
||||||
{"Year", "2006 6 06 _6 __6 ___6", "2009 6 09 _6 __6 ___6"},
|
{"Year", "2006 6 06 _6 __6 ___6", "2009 6 09 _6 __6 ___6"},
|
||||||
{"Month", "Jan January 1 01 _1", "Feb February 2 02 _2"},
|
{"Month", "Jan January 1 01 _1", "Feb February 2 02 _2"},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue