Skip to content

Commit 896a086

Browse files
authored
This closes qax-os#2224, fix apply number format code panic cause by Chinese month name index overflow (qax-os#2225)
1 parent ccaddf2 commit 896a086

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

numfmt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,7 @@ var (
16371637
monthNamesChineseAbbr = []string{"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}
16381638
// monthNamesChineseNum list the month number and character abbreviation in
16391639
// the Chinese.
1640-
monthNamesChineseNum = []string{"0月", "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月"}
1640+
monthNamesChineseNum = []string{"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"}
16411641
// monthNamesCorsican list the month names in the Corsican.
16421642
monthNamesCorsican = []string{"ghjennaghju", "ferraghju", "marzu", "aprile", "maghju", "ghjunghju", "lugliu", "aostu", "settembre", "ottobre", "nuvembre", "dicembre"}
16431643
// monthNamesCorsican lists the month name abbreviations in the Corsican.
@@ -5966,7 +5966,7 @@ func localMonthsNameCherokee(t time.Time, abbr int) string {
59665966
// localMonthsNameChinese1 returns the Chinese name of the month.
59675967
func localMonthsNameChinese1(t time.Time, abbr int) string {
59685968
if abbr == 3 {
5969-
return monthNamesChineseNum[t.Month()]
5969+
return monthNamesChineseNum[t.Month()-1]
59705970
}
59715971
if abbr == 4 {
59725972
return monthNamesChinese[int(t.Month())-1]
@@ -5985,7 +5985,7 @@ func localMonthsNameChinese2(t time.Time, abbr int) string {
59855985
// localMonthsNameChinese3 returns the Chinese name of the month.
59865986
func localMonthsNameChinese3(t time.Time, abbr int) string {
59875987
if abbr == 3 || abbr == 4 {
5988-
return monthNamesChineseNum[t.Month()]
5988+
return monthNamesChineseNum[t.Month()-1]
59895989
}
59905990
return strconv.Itoa(int(t.Month()))
59915991
}

0 commit comments

Comments
 (0)