File tree Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Expand file tree Collapse file tree 1 file changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -144,29 +144,24 @@ void SdnToGregorian(
144
144
int year ;
145
145
int month ;
146
146
int day ;
147
- zend_long temp ;
147
+ int temp ;
148
148
int dayOfYear ;
149
149
150
- if (sdn <= 0 ||
151
- sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET ) / 4 ) {
152
- goto fail ;
153
- }
154
- temp = (sdn + GREGOR_SDN_OFFSET ) * 4 - 1 ;
155
-
156
- if (temp < 0 || (temp / DAYS_PER_400_YEARS ) > INT_MAX ) {
150
+ if (sdn < 1721426 || sdn > 5373484 ) {
157
151
goto fail ;
158
152
}
153
+ temp = (int )(sdn + GREGOR_SDN_OFFSET ) * 4 - 1 ; // temp <= 0x149ED63
159
154
160
155
/* Calculate the century (year/100). */
161
156
century = temp / DAYS_PER_400_YEARS ;
162
157
163
158
/* Calculate the year and day of year (1 <= dayOfYear <= 366). */
164
- temp = ((temp % DAYS_PER_400_YEARS ) / 4 ) * 4 + 3 ;
159
+ temp = ((temp % DAYS_PER_400_YEARS ) / 4 ) * 4 + 3 ; // temp <= 0x23AB3
165
160
year = (century * 100 ) + (temp / DAYS_PER_4_YEARS );
166
- dayOfYear = (temp % DAYS_PER_4_YEARS ) / 4 + 1 ;
161
+ dayOfYear = (temp % DAYS_PER_4_YEARS ) / 4 + 1 ; // dayOfYear = 0x16E
167
162
168
163
/* Calculate the month and day of month. */
169
- temp = dayOfYear * 5 - 3 ;
164
+ temp = dayOfYear * 5 - 3 ; // temp <= 723
170
165
month = temp / DAYS_PER_5_MONTHS ;
171
166
day = (temp % DAYS_PER_5_MONTHS ) / 5 + 1 ;
172
167
You can’t perform that action at this time.
0 commit comments