I propose the declaration of the following format constants to the time package:
const (
DateTime = "2006-01-02 15:04:05"
DateOnly = "2006-01-02"
)
Analyzing all Go code on the module proxy (as of 2022-04-01), here's a table of all common time formats sorted in popularity order:
| Rank |
Frequency |
Format |
| 1 |
75616 |
time.RFC3339 |
| 2 |
23954 |
time.RFC3339Nano |
| 3 |
13312 |
"2006-01-02 15:04:05" |
| 4 |
12332 |
"2006-01-02" |
| 5 |
11940 |
time.RFC1123 |
| 6 |
2998 |
time.RFC1123Z |
| 7 |
2871 |
time.UnixDate |
| 8 |
2843 |
time.ANSIC |
| 9 |
2820 |
"20060102" |
| 10 |
2600 |
time.RFC822 |
| 11 |
2522 |
time.Kitchen |
| 12 |
2499 |
"20060102150405" |
| 13 |
2225 |
"15:04:05" |
| 14 |
1503 |
time.RFC850 |
| 15 |
1410 |
time.Stamp |
| 16 |
1374 |
"2006-01-02T15:04:05Z" |
| 17 |
1302 |
"2006-01-02T15:04:05" |
| 18 |
1152 |
"2006" |
| 19 |
1149 |
"2006/01/02 15:04:05" |
| 20 |
1133 |
time.StampMilli |
| 21 |
1122 |
time.RFC822Z |
| 22 |
1059 |
time.RubyDate |
| 23 |
962 |
"15:04" |
| 24 |
934 |
"2006-01-02 15:04:05.000" |
| 25 |
879 |
"2006010215" |
| 26 |
685 |
"15:04:05.000" |
| 27 |
668 |
"2006-01-02 15:04" |
| 28 |
646 |
"2006/01/02 - 15:04:05" |
| 29 |
637 |
"2006/01/02" |
| 30 |
552 |
time.StampNano |
| 31 |
533 |
time.StampMicro |
As can be seen, "2006-01-02 15:04:05" and "2006-01-02" are the 3rd and 4th most popular format constants. They are more popular than most of the other time format constants that did get a named declaration.
Given their popularity, I propose declaring:
const (
DateTime = "2006-01-02 15:04:05"
DateOnly = "2006-01-02"
)
Other constant name suggestions welcome.
I propose the declaration of the following format constants to the
timepackage:Analyzing all Go code on the module proxy (as of 2022-04-01), here's a table of all common time formats sorted in popularity order:
time.RFC3339time.RFC3339Nano"2006-01-02 15:04:05""2006-01-02"time.RFC1123time.RFC1123Ztime.UnixDatetime.ANSIC"20060102"time.RFC822time.Kitchen"20060102150405""15:04:05"time.RFC850time.Stamp"2006-01-02T15:04:05Z""2006-01-02T15:04:05""2006""2006/01/02 15:04:05"time.StampMillitime.RFC822Ztime.RubyDate"15:04""2006-01-02 15:04:05.000""2006010215""15:04:05.000""2006-01-02 15:04""2006/01/02 - 15:04:05""2006/01/02"time.StampNanotime.StampMicroAs can be seen,
"2006-01-02 15:04:05"and"2006-01-02"are the 3rd and 4th most popular format constants. They are more popular than most of the othertimeformat constants that did get a named declaration.Given their popularity, I propose declaring:
Other constant name suggestions welcome.