@@ -103,11 +103,11 @@ private function _getConstellation($birthdayCode)
103
103
$ day = substr ($ birthdayCode , 6 , 2 );
104
104
105
105
// 1月份与12月份特殊处理
106
- if (($ month == 1 && $ day < 20 ) || ($ month == 12 && $ day > 21 )) {
106
+ if (($ month == ' 01 ' && $ day < 20 ) || ($ month == ' 12 ' && $ day > 21 )) {
107
107
return $ this ->_constellationList ['12 ' ]['name ' ];
108
- } elseif ($ month == 1 ) {
108
+ } elseif ($ month == ' 01 ' ) {
109
109
return $ this ->_constellationList ['01 ' ]['name ' ];
110
- } elseif ($ month == 12 ) {
110
+ } elseif ($ month == ' 12 ' ) {
111
111
return $ this ->_constellationList ['12 ' ]['name ' ];
112
112
}
113
113
@@ -116,10 +116,15 @@ private function _getConstellation($birthdayCode)
116
116
if (strtotime ($ startDate ) <= $ time && strtotime ($ endDate ) >= $ time ) {
117
117
return $ this ->_constellationList [$ month ]['name ' ];
118
118
}
119
- $ startDate = $ year .'- ' .$ this ->_constellationList [$ month - 1 ]['start_date ' ];
120
- $ endDate = $ year .'- ' .$ this ->_constellationList [$ month - 1 ]['end_date ' ];
119
+
120
+
121
+ $ key = (int )$ month - 1 ; // 1月份以特殊处理
122
+ $ key = strlen ($ key ) == 1 ? $ this ->_getStrPad ($ key ) : (string )$ key ;
123
+
124
+ $ startDate = $ year .'- ' .$ this ->_constellationList [$ key ]['start_date ' ];
125
+ $ endDate = $ year .'- ' .$ this ->_constellationList [$ key ]['end_date ' ];
121
126
if (strtotime ($ startDate ) <= $ time && strtotime ($ endDate ) >= $ time ) {
122
- return $ this ->_constellationList [$ month - 1 ]['name ' ];
127
+ return $ this ->_constellationList [$ key ]['name ' ];
123
128
}
124
129
125
130
return '' ;
0 commit comments