Skip to content

Commit

Permalink
Fix/workaround for http://bugs.php.net/27533
Browse files Browse the repository at this point in the history
  • Loading branch information
rlerdorf committed Mar 12, 2004
1 parent a967411 commit 259a07f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ext/standard/datetime.c
Expand Up @@ -161,7 +161,7 @@ void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
ta->tm_year = Z_LVAL_PP(arguments[5])
- ((Z_LVAL_PP(arguments[5]) > 1000) ? 1900 : 0);
/* fall-through */
case 5: /* day in month (1-baesd) */
case 5: /* day in month (1-based) */
val = (*arguments[4])->value.lval;
if (val < 1) {
chgsecs += (1-val) * 60*60*24;
Expand Down Expand Up @@ -192,8 +192,14 @@ void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
/* fall-through */
case 1: /* hour */
val = (*arguments[0])->value.lval;
if (val < 1) {
chgsecs += (1-val) * 60*60; val = 1;
/*
We don't use 1 here to work around problems in some mktime implementations
when it comes to daylight savings time. Setting it to 2 and working back from
there with the chgsecs offset makes us immune to these problems.
See http://bugs.php.net/27533 for more info.
*/
if (val < 2) {
chgsecs += (2-val) * 60*60; val = 2;
}
ta->tm_hour = val;
/* fall-through */
Expand Down

0 comments on commit 259a07f

Please sign in to comment.