Skip to content

Commit 4db1008

Browse files
committed
docs: correct zodiac animal names and formatting in comments
- Change typo of '子' to '鸡' in zodiac animals list. - Ensure consistency in comment formatting by adding spaces after commas. - Update Chinese month names to include '月' character, and adjust related comments. - Make code more readable by wrapping long lines and improving comment alignment. - Correct spelling and capitalization errors in comments. - Address potential formatting issues in code examples.
1 parent 57a165d commit 4db1008

File tree

7 files changed

+127
-118
lines changed

7 files changed

+127
-118
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Calendar Date object interface
2+
23
```
34
chronos.New() //Create current time
45
chronos.New(time.Now()) //The parameter is of type time.Time
56
chronos.New("2017/11/14 08:17") //Parameter is a specified format string
67
```
78

89
# Lunar 农历日期显示
10+
911
```
1012
chronos.New().Lunar() //Get the lunar calendar
1113
```
14+
1215
# Solar 公历日期显示
16+
1317
```
1418
chornos.New().Solar() //Get the solar calendar
1519
```

README_CN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Calendar 日期对象接口
2+
23
```
34
chronos.New() //创建当前时间
45
chronos.New(time.Now()) //该参数的类型为time.Time
56
chronos.New("2017/11/14 08:17") //参数是指定格式的字符串#年/月/日 时:分#
67
```
78

89
# Lunar 农历日期显示
10+
911
```
1012
chronos.New().Lunar() //获取月历
1113
```
14+
1215
# Solar 公历日期显示
16+
1317
```
1418
chornos.New().Solar() //获取日历
1519
```

calendar.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ type Calendar interface {
1919
LunarDate() string
2020
}
2121

22-
//New can input three type of time to create the calendar
23-
//"2006/01/02 03:04" format string
22+
// New can input three type of time to create the calendar
23+
// "2006/01/02 03:04" format string
2424
// time.Time value
2525
// or nil to create a new time.Now() value
2626
func New(v ...interface{}) Calendar {

data.go

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -25,77 +25,77 @@ var earthyBranch = []string{
2525
}
2626

2727
var zodiacs = []string{
28-
`鼠`, `牛`, `虎`, `兔`, `龙`, `蛇`, `马`, `羊`, `猴`, ``, `狗`, `猪`,
28+
`鼠`, `牛`, `虎`, `兔`, `龙`, `蛇`, `马`, `羊`, `猴`, ``, `狗`, `猪`,
2929
}
3030

3131
var stemBranchTable = []string{
32-
`甲子`, `乙丑`, `丙寅`, `丁卯`, `戊辰`, `己巳`, `庚午`, `辛未`, `壬申`, `癸酉`, `甲戌`, `乙亥`, //甲或己日
33-
`丙子`, `丁丑`, `戊寅`, `己卯`, `庚辰`, `辛巳`, `壬午`, `癸未`, `甲申`, `乙酉`, `丙戌`, `丁亥`, //乙或庚日
34-
`戊子`, `己丑`, `庚寅`, `辛卯`, `壬辰`, `癸巳`, `甲午`, `乙未`, `丙申`, `丁酉`, `戊戌`, `己亥`, //丙或辛日
35-
`庚子`, `辛丑`, `壬寅`, `癸卯`, `甲辰`, `乙巳`, `丙午`, `丁未`, `戊申`, `己酉`, `庚戌`, `辛亥`, //丁或壬日
36-
`壬子`, `癸丑`, `甲寅`, `乙卯`, `丙辰`, `丁巳`, `戊午`, `己未`, `庚申`, `辛酉`, `壬戌`, `癸亥`, //戊或癸日
32+
`甲子`, `乙丑`, `丙寅`, `丁卯`, `戊辰`, `己巳`, `庚午`, `辛未`, `壬申`, `癸酉`, `甲戌`, `乙亥`, // 甲或己日
33+
`丙子`, `丁丑`, `戊寅`, `己卯`, `庚辰`, `辛巳`, `壬午`, `癸未`, `甲申`, `乙酉`, `丙戌`, `丁亥`, // 乙或庚日
34+
`戊子`, `己丑`, `庚寅`, `辛卯`, `壬辰`, `癸巳`, `甲午`, `乙未`, `丙申`, `丁酉`, `戊戌`, `己亥`, // 丙或辛日
35+
`庚子`, `辛丑`, `壬寅`, `癸卯`, `甲辰`, `乙巳`, `丙午`, `丁未`, `戊申`, `己酉`, `庚戌`, `辛亥`, // 丁或壬日
36+
`壬子`, `癸丑`, `甲寅`, `乙卯`, `丙辰`, `丁巳`, `戊午`, `己未`, `庚申`, `辛酉`, `壬戌`, `癸亥`, // 戊或癸日
3737
}
3838

3939
var yearNumber = []int{
40-
0x9, 0xE, 0x13, 0x18, 0x1E, 0x23, 0x28, 0x2D, 0x33, 0x38, //1900-1909
41-
0x1, 0x6, 0xC, 0x11, 0x16, 0x1B, 0x21, 0x26, 0x2B, 0x30, //1910-1919
42-
0x36, 0x3B, 0x4, 0x9, 0xF, 0x14, 0x19, 0x1E, 0x24, 0x36, //1920-1929
43-
0x2E, 0x33, 0x39, 0x2, 0x7, 0xC, 0x12, 0x17, 0x1C, 0x2E, //1930-1939
44-
0x27, 0x2C, 0x31, 0x36, 0x0, 0x5, 0xA, 0xF, 0x15, 0x1A, //1940-1949
45-
0x1F, 0x24, 0x2A, 0x2F, 0x34, 0x39, 0x3, 0x8, 0xD, 0x12, //1950-1959
46-
0x18, 0x1D, 0x22, 0x27, 0x2D, 0x32, 0x37, 0x0, 0x6, 0xB, //1960-1969
47-
0x10, 0x15, 0x1B, 0x20, 0x25, 0x2A, 0x30, 0x35, 0x3A, 0x3, //1970-1979
48-
0x9, 0xE, 0x13, 0x18, 0x1E, 0x23, 0x28, 0x2D, 0x33, 0x38, //1980-1989
49-
0x1, 0x6, 0xC, 0x11, 0x16, 0x1B, 0x21, 0x26, 0x2B, 0x30, //1990-1999
50-
0x36, 0x3B, 0x4, 0x9, 0xF, 0x14, 0x19, 0x1E, 0x24, 0x29, //2000-2009
51-
0x2E, 0x33, 0x39, 0x2, 0x7, 0xC, 0x12, 0x17, 0x1C, 0x21, //2010-2019
52-
0x27, 0x2C, 0x31, 0x36, 0x0, 0x5, 0xA, 0xF, 0x15, 0x1A, //2020-2029
53-
0x1F, 0x24, 0x2A, 0x2F, 0x34, 0x39, 0x3, 0x8, 0xD, 0x12, //2030-2039
54-
0x18, 0x1D, 0x22, 0x27, 0x2D, 0x32, 0x37, 0x0, 0x6, 0xB, //2040-2049
55-
0x10, 0x15, 0x1B, 0x20, 0x25, 0x2A, 0x30, 0x35, 0x3A, 0x3, //2050-2059
56-
0x9, 0xE, 0x13, 0x18, 0x1E, 0x23, 0x28, 0x2D, 0x33, 0x38, //2060-2069
57-
0x1, 0x6, 0xC, 0x11, 0x16, 0x1B, 0x21, 0x26, 0x2B, 0x30, //2070-2079
58-
0x36, 0x3B, 0x4, 0x9, 0xF, 0x14, 0x19, 0x1E, 0x24, 0x29, //2080-2089
59-
0x2E, 0x33, 0x39, 0x2, 0x7, 0xC, 0x12, 0x17, 0x1C, 0x21, //2090-2099
40+
0x9, 0xE, 0x13, 0x18, 0x1E, 0x23, 0x28, 0x2D, 0x33, 0x38, // 1900-1909
41+
0x1, 0x6, 0xC, 0x11, 0x16, 0x1B, 0x21, 0x26, 0x2B, 0x30, // 1910-1919
42+
0x36, 0x3B, 0x4, 0x9, 0xF, 0x14, 0x19, 0x1E, 0x24, 0x36, // 1920-1929
43+
0x2E, 0x33, 0x39, 0x2, 0x7, 0xC, 0x12, 0x17, 0x1C, 0x2E, // 1930-1939
44+
0x27, 0x2C, 0x31, 0x36, 0x0, 0x5, 0xA, 0xF, 0x15, 0x1A, // 1940-1949
45+
0x1F, 0x24, 0x2A, 0x2F, 0x34, 0x39, 0x3, 0x8, 0xD, 0x12, // 1950-1959
46+
0x18, 0x1D, 0x22, 0x27, 0x2D, 0x32, 0x37, 0x0, 0x6, 0xB, // 1960-1969
47+
0x10, 0x15, 0x1B, 0x20, 0x25, 0x2A, 0x30, 0x35, 0x3A, 0x3, // 1970-1979
48+
0x9, 0xE, 0x13, 0x18, 0x1E, 0x23, 0x28, 0x2D, 0x33, 0x38, // 1980-1989
49+
0x1, 0x6, 0xC, 0x11, 0x16, 0x1B, 0x21, 0x26, 0x2B, 0x30, // 1990-1999
50+
0x36, 0x3B, 0x4, 0x9, 0xF, 0x14, 0x19, 0x1E, 0x24, 0x29, // 2000-2009
51+
0x2E, 0x33, 0x39, 0x2, 0x7, 0xC, 0x12, 0x17, 0x1C, 0x21, // 2010-2019
52+
0x27, 0x2C, 0x31, 0x36, 0x0, 0x5, 0xA, 0xF, 0x15, 0x1A, // 2020-2029
53+
0x1F, 0x24, 0x2A, 0x2F, 0x34, 0x39, 0x3, 0x8, 0xD, 0x12, // 2030-2039
54+
0x18, 0x1D, 0x22, 0x27, 0x2D, 0x32, 0x37, 0x0, 0x6, 0xB, // 2040-2049
55+
0x10, 0x15, 0x1B, 0x20, 0x25, 0x2A, 0x30, 0x35, 0x3A, 0x3, // 2050-2059
56+
0x9, 0xE, 0x13, 0x18, 0x1E, 0x23, 0x28, 0x2D, 0x33, 0x38, // 2060-2069
57+
0x1, 0x6, 0xC, 0x11, 0x16, 0x1B, 0x21, 0x26, 0x2B, 0x30, // 2070-2079
58+
0x36, 0x3B, 0x4, 0x9, 0xF, 0x14, 0x19, 0x1E, 0x24, 0x29, // 2080-2089
59+
0x2E, 0x33, 0x39, 0x2, 0x7, 0xC, 0x12, 0x17, 0x1C, 0x21, // 2090-2099
6060
}
6161

6262
var monthNumber = []int{
63-
0x6, //next year 1
64-
0x25, //next year 2
65-
0x0, //3
66-
0x1F, //4
67-
0x1, //5
68-
0x20, //6
69-
0x2, //7
70-
0x21, //8
71-
0x4, //9
72-
0x22, //10
73-
0x5, //11
74-
0x23, //12
63+
0x6, // next year 1
64+
0x25, // next year 2
65+
0x0, // 3
66+
0x1F, // 4
67+
0x1, // 5
68+
0x20, // 6
69+
0x2, // 7
70+
0x21, // 8
71+
0x4, // 9
72+
0x22, // 10
73+
0x5, // 11
74+
0x23, // 12
7575
}
7676

7777
var lunarInfoList = []int{
78-
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, //1900-1909
79-
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, //1910-1919
80-
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, //1920-1929
81-
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, //1930-1939
82-
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, //1940-1949
83-
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, //1950-1959
84-
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, //1960-1969
85-
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, //1970-1979
86-
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, //1980-1989
87-
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, //1990-1999
88-
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, //2000-2009
89-
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, //2010-2019
90-
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, //2020-2029
91-
0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, //2030-2039
92-
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, //2040-2049
93-
0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, //2050-2059
94-
0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, //2060-2069
95-
0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, //2070-2079
96-
0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, //2080-2089
97-
0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, //2090-2099
98-
0x0d520, //2100
78+
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900-1909
79+
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910-1919
80+
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920-1929
81+
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, // 1930-1939
82+
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, // 1940-1949
83+
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, // 1950-1959
84+
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, // 1960-1969
85+
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, // 1970-1979
86+
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, // 1980-1989
87+
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, // 1990-1999
88+
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000-2009
89+
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, // 2010-2019
90+
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, // 2020-2029
91+
0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, // 2030-2039
92+
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, // 2040-2049
93+
0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, // 2050-2059
94+
0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, // 2060-2069
95+
0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, // 2070-2079
96+
0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, // 2080-2089
97+
0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, // 2090-2099
98+
0x0d520, // 2100
9999
}
100100

101101
var termInfoList = []string{
@@ -139,19 +139,19 @@ var termInfoList = []string{
139139
`665f67f0e37f14898082b0723b02d5`, `7ec967f0e37f14998082b0787b0721`, `7f07e7f0e47f531b0723b0b6fb0722`, `7f0e36665b66a449801e9808297c35`, `665f67f0e37f14898082b0723b02d5`,
140140
`7ec967f0e37f14998082b0787b06bd`, `7f07e7f0e47f531b0723b0b6fb0721`, `7f0e36665b66a449801e9808297c35`, `665f67f0e37f14898082b072297c35`, `7ec967f0e37f14998082b0787b06bd`,
141141
`7f07e7f0e47f531b0723b0b6fb0721`, `7f0e26665b66a449801e9808297c35`, `665f67f0e37f1489801eb072297c35`, `7ec967f0e37f14998082b0787b06bd`, `7f07e7f0e47f531b0723b0b6fb0721`,
142-
`7f0e27f1487f531b0b0bb0b6fb0722`, //2100
142+
`7f0e27f1487f531b0b0bb0b6fb0722`, // 2100
143143
}
144144

145145
var number = []string{`一`, `二`, `三`, `四`, `五`, `六`, `七`, `八`, `九`, `十`, `十一`, `十二`}
146146
var ten = []string{`初`, `十`, `廿`, `卅`}
147147

148-
//月历月份
148+
// 月历月份
149149
var chineseNumber = []string{`正`, `二`, `三`, `四`, `五`, `六`, `七`, `八`, `九`, `十`, `十一`, `腊`}
150150

151-
//公历每个月份的天数
151+
// 公历每个月份的天数
152152
var monthDay = []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
153153

154-
//12星座
154+
// 12星座
155155
var constellation = []string{
156156
`魔羯`, `水瓶`, `双鱼`, `白羊`, `金牛`, `双子`, `巨蟹`, `狮子`, `处女`, `天秤`, `天蝎`, `射手`,
157157
}
@@ -160,7 +160,7 @@ func fixSuffix(y int) int {
160160
return y - 1900
161161
}
162162

163-
//GetLunarInfo 取得月历信息
163+
// GetLunarInfo 取得月历信息
164164
func GetLunarInfo(y int) int {
165165
y = fixSuffix(y)
166166
if y < 0 || y > len(lunarInfoList) {
@@ -191,15 +191,15 @@ func getChineseYear(year int) string {
191191
return StemBranchYear(year) + "年"
192192
}
193193

194-
//getChineseMonth 取得月历月
194+
// getChineseMonth 取得月历月
195195
func getChineseMonth(m int) string {
196196
if m > 12 || m < 1 {
197197
return "?月"
198198
}
199-
return chineseNumber[m-1] + "月" //加上月字
199+
return chineseNumber[m-1] + "月" // 加上月字
200200
}
201201

202-
//getChineseDay 取得月历日
202+
// getChineseDay 取得月历日
203203
func getChineseDay(d int) string {
204204
if d < 0 || d > 31 {
205205
return "?日"
@@ -220,28 +220,28 @@ func getChineseDay(d int) string {
220220

221221
}
222222

223-
//GetStemBranch 取得干支
223+
// GetStemBranch 取得干支
224224
func GetStemBranch(y int) string {
225225
return heavenlyStem[y%10] + earthyBranch[y%12]
226226
}
227227

228-
//StemBranchHour 获取时柱
229-
//  子   丑   寅   卯   辰   己
230-
//   23-01:01-03:03-05 :05-07:07-09:09-11
231-
//   午   未   申   酉   戊   亥
232-
//   11-13:13-15:15-17:17-19:19-21:21-23
233-
//`甲子`, `乙丑`, `丙寅`, `丁卯`, `戊辰`, `己巳`, `庚午`, `辛未`, `壬申`, `癸酉`, `甲戌`, `乙亥`, //甲或己日
234-
//`丙子`, `丁丑`, `戊寅`, `己卯`, `庚辰`, `辛巳`, `壬午`, `癸未`, `甲申`, `乙酉`, `丙戌`, `丁亥`, //乙或庚日
235-
//`戊子`, `己丑`, `庚寅`, `辛卯`, `壬辰`, `癸巳`, `甲午`, `乙未`, `丙申`, `丁酉`, `戊戌`, `己亥`, //丙或辛日
236-
//`庚子`, `辛丑`, `壬寅`, `癸卯`, `甲辰`, `乙巳`, `丙午`, `丁未`, `戊申`, `己酉`, `庚戌`, `辛亥`, //丁或壬日
237-
//`壬子`, `癸丑`, `甲寅`, `乙卯`, `丙辰`, `丁巳`, `戊午`, `己未`, `庚申`, `辛酉`, `壬戌`, `癸亥`, //戊或癸日
228+
// StemBranchHour 获取时柱
229+
//   子   丑   寅   卯   辰   己
230+
//    23-01:01-03:03-05 :05-07:07-09:09-11
231+
//    午   未   申   酉   戊   亥
232+
//    11-13:13-15:15-17:17-19:19-21:21-23
233+
// `甲子`, `乙丑`, `丙寅`, `丁卯`, `戊辰`, `己巳`, `庚午`, `辛未`, `壬申`, `癸酉`, `甲戌`, `乙亥`, //甲或己日
234+
// `丙子`, `丁丑`, `戊寅`, `己卯`, `庚辰`, `辛巳`, `壬午`, `癸未`, `甲申`, `乙酉`, `丙戌`, `丁亥`, //乙或庚日
235+
// `戊子`, `己丑`, `庚寅`, `辛卯`, `壬辰`, `癸巳`, `甲午`, `乙未`, `丙申`, `丁酉`, `戊戌`, `己亥`, //丙或辛日
236+
// `庚子`, `辛丑`, `壬寅`, `癸卯`, `甲辰`, `乙巳`, `丙午`, `丁未`, `戊申`, `己酉`, `庚戌`, `辛亥`, //丁或壬日
237+
// `壬子`, `癸丑`, `甲寅`, `乙卯`, `丙辰`, `丁巳`, `戊午`, `己未`, `庚申`, `辛酉`, `壬戌`, `癸亥`, //戊或癸日
238238
func StemBranchHour(y, m, d, h int) string {
239239
i := stemBranchIndex(y, m, d) % 5 * 12
240240
idx := (h + 1) / 2 % 12
241241
return stemBranchTable[fixDayNext(i, idx, h)]
242242
}
243243

244-
//待优化
244+
// 待优化
245245
func fixDayNext(row int, idx int, hour int) int {
246246
if hour >= 23 {
247247
idx += 12
@@ -269,20 +269,20 @@ func StemBranchDay(y, m, d int) string {
269269
return stemBranchTable[stemBranchIndex(y, m, d)]
270270
}
271271

272-
//StemBranchMonth 获取月柱
272+
// StemBranchMonth 获取月柱
273273
func StemBranchMonth(y, m, d int) string {
274-
//月柱 1900年1月小寒以前为 丙子月(60进制12)
275-
fir := GetTermInfo(y, m*2-1) //返回当月「节」为几日开始
274+
// 月柱 1900年1月小寒以前为 丙子月(60进制12)
275+
fir := GetTermInfo(y, m*2-1) // 返回当月「节」为几日开始
276276

277-
//依据12节气修正干支月
277+
// 依据12节气修正干支月
278278
var sb = GetStemBranch(fixSuffix(y)*12 + m + 11)
279279
if d >= fir {
280280
sb = GetStemBranch(fixSuffix(y)*12 + m + 12)
281281
}
282282
return sb
283283
}
284284

285-
//StemBranchYear 获取年柱
285+
// StemBranchYear 获取年柱
286286
func StemBranchYear(y int) string {
287287
num := y - 4
288288
return heavenlyStem[num%10] + earthyBranch[num%12]

0 commit comments

Comments
 (0)