@@ -103,11 +103,11 @@ private function _getConstellation($birthdayCode)
103103 $ day = substr ($ birthdayCode , 6 , 2 );
104104
105105 // 1月份与12月份特殊处理
106- if (($ month == 1 && $ day < 20 ) || ($ month == 12 && $ day > 21 )) {
106+ if (($ month == ' 01 ' && $ day < 20 ) || ($ month == ' 12 ' && $ day > 21 )) {
107107 return $ this ->_constellationList ['12 ' ]['name ' ];
108- } elseif ($ month == 1 ) {
108+ } elseif ($ month == ' 01 ' ) {
109109 return $ this ->_constellationList ['01 ' ]['name ' ];
110- } elseif ($ month == 12 ) {
110+ } elseif ($ month == ' 12 ' ) {
111111 return $ this ->_constellationList ['12 ' ]['name ' ];
112112 }
113113
@@ -116,10 +116,15 @@ private function _getConstellation($birthdayCode)
116116 if (strtotime ($ startDate ) <= $ time && strtotime ($ endDate ) >= $ time ) {
117117 return $ this ->_constellationList [$ month ]['name ' ];
118118 }
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 ' ];
121126 if (strtotime ($ startDate ) <= $ time && strtotime ($ endDate ) >= $ time ) {
122- return $ this ->_constellationList [$ month - 1 ]['name ' ];
127+ return $ this ->_constellationList [$ key ]['name ' ];
123128 }
124129
125130 return '' ;
0 commit comments