-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathdata.go
More file actions
37 lines (31 loc) · 804 Bytes
/
Copy pathdata.go
File metadata and controls
37 lines (31 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package chronos
var chineseNumbers = [...]string{"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"}
var chineseTenPrefix = [...]string{"初", "十", "廿", "卅"}
var chineseMonthNames = [...]string{"正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "冬", "腊"}
func getChineseYear(year int) string {
return nianZhuChinese(year) + "年"
}
func getChineseMonth(m int) string {
if m > 12 || m < 1 {
return "?月"
}
return chineseMonthNames[m-1] + "月"
}
func getChineseDay(d int) string {
if d < 0 || d > 31 {
return "?日"
}
var s string
switch d {
case 10:
s = `初十`
case 20:
s = `二十`
case 30:
s = `三十`
default:
n := (d - 1) % 10
s = chineseTenPrefix[d/10] + chineseNumbers[n]
}
return s + "日"
}