Fix date parse for "2016-03-06 15:28:01 +0900"

This commit is contained in:
Kento Tsuji 2021-08-16 02:48:01 +09:00 committed by GitHub
parent 3f42935ca9
commit 88075729b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -1211,6 +1211,8 @@ func TestToTime(t *testing.T) {
{"2016-03-06 15:28:01", time.Date(2016, 3, 6, 15, 28, 1, 0, time.UTC), false}, {"2016-03-06 15:28:01", time.Date(2016, 3, 6, 15, 28, 1, 0, time.UTC), false},
{"2016-03-06 15:28:01 -0000", time.Date(2016, 3, 6, 15, 28, 1, 0, time.UTC), false}, {"2016-03-06 15:28:01 -0000", time.Date(2016, 3, 6, 15, 28, 1, 0, time.UTC), false},
{"2016-03-06 15:28:01 -00:00", time.Date(2016, 3, 6, 15, 28, 1, 0, time.UTC), false}, {"2016-03-06 15:28:01 -00:00", time.Date(2016, 3, 6, 15, 28, 1, 0, time.UTC), false},
{"2016-03-06 15:28:01 +0900", time.Date(2016, 3, 6, 6, 28, 1, 0, time.UTC), false},
{"2016-03-06 15:28:01 +09:00", time.Date(2016, 3, 6, 6, 28, 1, 0, time.UTC), false},
{"2006-01-02", time.Date(2006, 1, 2, 0, 0, 0, 0, time.UTC), false}, {"2006-01-02", time.Date(2006, 1, 2, 0, 0, 0, 0, time.UTC), false},
{"02 Jan 2006", time.Date(2006, 1, 2, 0, 0, 0, 0, time.UTC), false}, {"02 Jan 2006", time.Date(2006, 1, 2, 0, 0, 0, 0, time.UTC), false},
{1472574600, time.Date(2016, 8, 30, 16, 30, 0, 0, time.UTC), false}, {1472574600, time.Date(2016, 8, 30, 16, 30, 0, 0, time.UTC), false},

View File

@ -1296,8 +1296,8 @@ var (
timeFormat{"2006-01-02 15:04:05Z07:00", timeFormatNumericTimezone}, timeFormat{"2006-01-02 15:04:05Z07:00", timeFormatNumericTimezone},
timeFormat{"2006-01-02", timeFormatNoTimezone}, timeFormat{"2006-01-02", timeFormatNoTimezone},
timeFormat{"02 Jan 2006", timeFormatNoTimezone}, timeFormat{"02 Jan 2006", timeFormatNoTimezone},
timeFormat{"2006-01-02 15:04:05 -07:00", 1}, timeFormat{"2006-01-02 15:04:05 -07:00", timeFormatNumericTimezone},
timeFormat{"2006-01-02 15:04:05 -0700", 1}, timeFormat{"2006-01-02 15:04:05 -0700", timeFormatNumericTimezone},
timeFormat{time.Kitchen, timeFormatTimeOnly}, timeFormat{time.Kitchen, timeFormatTimeOnly},
timeFormat{time.Stamp, timeFormatTimeOnly}, timeFormat{time.Stamp, timeFormatTimeOnly},
timeFormat{time.StampMilli, timeFormatTimeOnly}, timeFormat{time.StampMilli, timeFormatTimeOnly},