mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
- Fixed bug in SdnToGregorian (see comments on #53574, though that bug is about
another function). NEWS & tests tomorrow.
This commit is contained in:
parent
4e4ad9aa26
commit
05389f7752
1 changed files with 9 additions and 9 deletions
|
@ -127,6 +127,7 @@
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "sdncal.h"
|
#include "sdncal.h"
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#define GREGOR_SDN_OFFSET 32045
|
#define GREGOR_SDN_OFFSET 32045
|
||||||
#define DAYS_PER_5_MONTHS 153
|
#define DAYS_PER_5_MONTHS 153
|
||||||
|
@ -146,19 +147,14 @@ void SdnToGregorian(
|
||||||
long int temp;
|
long int temp;
|
||||||
int dayOfYear;
|
int dayOfYear;
|
||||||
|
|
||||||
if (sdn <= 0) {
|
if (sdn <= 0 ||
|
||||||
*pYear = 0;
|
sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) {
|
||||||
*pMonth = 0;
|
goto fail;
|
||||||
*pDay = 0;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
|
temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1;
|
||||||
|
|
||||||
if (temp < 0) {
|
if (temp < 0) {
|
||||||
*pYear = 0;
|
goto fail;
|
||||||
*pMonth = 0;
|
|
||||||
*pDay = 0;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the century (year/100). */
|
/* Calculate the century (year/100). */
|
||||||
|
@ -190,6 +186,10 @@ void SdnToGregorian(
|
||||||
*pYear = year;
|
*pYear = year;
|
||||||
*pMonth = month;
|
*pMonth = month;
|
||||||
*pDay = day;
|
*pDay = day;
|
||||||
|
fail:
|
||||||
|
*pYear = 0;
|
||||||
|
*pMonth = 0;
|
||||||
|
*pDay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long int GregorianToSdn(
|
long int GregorianToSdn(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue