diff options
author | Cholerae Hu <choleraehyq@gmail.com> | 2017-07-25 14:04:50 +0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2017-09-08 12:50:14 +0000 |
commit | 32e117d971eb4f802f27b98a0f13b7d9fc2d73fb (patch) | |
tree | 38ee502f1e217f4f7e65277137bed970b274017a /src/time/format.go | |
parent | a323656bb3edce6b2913a4946be8481ef1311afc (diff) | |
download | go-32e117d971eb4f802f27b98a0f13b7d9fc2d73fb.tar.gz go-32e117d971eb4f802f27b98a0f13b7d9fc2d73fb.zip |
time: don't match '---' month in time.Parse
The existing implementation will panic when month in date string is '---'.
Fixed #21113
Change-Id: I8058ae7a4102e882f8b7e9c65d80936b563265e4
Reviewed-on: https://go-review.googlesource.com/51010
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/time/format.go')
-rw-r--r-- | src/time/format.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/time/format.go b/src/time/format.go index c960df0197..05f734eae7 100644 --- a/src/time/format.go +++ b/src/time/format.go @@ -289,7 +289,6 @@ var shortDayNames = []string{ } var shortMonthNames = []string{ - "---", "Jan", "Feb", "Mar", @@ -305,7 +304,6 @@ var shortMonthNames = []string{ } var longMonthNames = []string{ - "---", "January", "February", "March", @@ -841,8 +839,10 @@ func parse(layout, value string, defaultLocation, local *Location) (Time, error) year, err = atoi(p) case stdMonth: month, value, err = lookup(shortMonthNames, value) + month++ case stdLongMonth: month, value, err = lookup(longMonthNames, value) + month++ case stdNumMonth, stdZeroMonth: month, value, err = getnum(value, std == stdZeroMonth) if month <= 0 || 12 < month { |