This closes #1060, fix build-in time number format parse error

pull/2/head
xuri 3 years ago
parent 6b277c61d2
commit 9b0aa7ac30
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

@ -981,22 +981,33 @@ func parseTime(v string, format string) string {
{"D", "2"},
{"yyyy", "2006"},
{"yy", "06"},
{"MMMM", "%%%%"},
{"mmmm", "%%%%"},
{"DDDD", "&&&&"},
{"dddd", "&&&&"},
{"DD", "02"},
{"dd", "02"},
{"D", "2"},
{"d", "2"},
{"MMM", "Jan"},
{"mmm", "Jan"},
{"MMSS", "0405"},
{"mmss", "0405"},
{"SS", "05"},
{"ss", "05"},
{"s", "5"},
{"MM:", "04:"},
{"mm:", "04:"},
{":MM", ":04"},
{":mm", ":04"},
{"m:", "4:"},
{":m", ":4"},
{"MM", "01"},
{"mm", "01"},
{"am/pm", "pm"},
{"AM/PM", "PM"},
{"am/pm", "PM"},
{"M/", "1/"},
{"m/", "1/"},
{"m", "1"},
{"%%%%", "January"},
{"&&&&", "Monday"},
}

@ -307,6 +307,7 @@ func TestParseTime(t *testing.T) {
assert.Equal(t, "3/4/2019 5:5:42", parseTime("43528.2123", "M/D/YYYY h:m:s"))
assert.Equal(t, "3/4/2019 0:5:42", parseTime("43528.003958333335", "m/d/yyyy h:m:s"))
assert.Equal(t, "3/4/2019 0:05:42", parseTime("43528.003958333335", "M/D/YYYY h:mm:s"))
assert.Equal(t, "3:30:00 PM", parseTime("0.64583333333333337", "h:mm:ss am/pm"))
assert.Equal(t, "0:05", parseTime("43528.003958333335", "h:mm"))
assert.Equal(t, "0:0", parseTime("6.9444444444444444E-5", "h:m"))
assert.Equal(t, "0:00", parseTime("6.9444444444444444E-5", "h:mm"))

Loading…
Cancel
Save