cvs: php4 /ext/standard datetime.c
| From: | James Moore | Date: | Sat, 03 Nov 2001 12:42:42 +0000 |
| Subject: | cvs: php4 /ext/standard datetime.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-8064@lists.php.net to get a copy of this message | ||
jmoore Sat Nov 3 07:42:42 2001 EDT
Modified files:
/php4/ext/standard datetime.c
Log:
@ - Fix bug 13885 (gmdate timezone handling on windows) (jmoore)
- relying on timezone and tzname isnt OK for gmdate etc, the only behaviour
that might not be right is the handling of T formatter under gmdate
should it return the machines timezone or GMT Standard Time??
Index: php4/ext/standard/datetime.c
diff -u php4/ext/standard/datetime.c:1.78 php4/ext/standard/datetime.c:1.79
--- php4/ext/standard/datetime.c:1.78 Tue Sep 25 18:48:43 2001
+++ php4/ext/standard/datetime.c Sat Nov 3 07:42:41 2001
@@ -19,7 +19,7 @@
*/
-/* $Id: datetime.c,v 1.78 2001/09/25 22:48:43 jeroen Exp $ */
+/* $Id: datetime.c,v 1.79 2001/11/03 12:42:41 jmoore Exp $ */
#include "php.h"
@@ -220,6 +220,10 @@
struct tm *ta, tmbuf;
int i, size = 0, length, h, beat, fd, wd, yd, wk;
char tmp_buff[32];
+#if !HAVE_TM_GMTOFF
+ long tzone;
+ char *tname[2]= {"GMT Standard Time", "BST"};
+#endif
switch(ZEND_NUM_ARGS()) {
case 1:
@@ -242,8 +246,15 @@
if (gm) {
ta = php_gmtime_r(&the_time, &tmbuf);
+#if !HAVE_TM_GMTOFF
+ tzone = 0;
+#endif
} else {
ta = php_localtime_r(&the_time, &tmbuf);
+#if !HAVE_TM_GMTOFF
+ tzone = timezone;
+ tname[0] = tzname[0];
+#endif
}
if (!ta) { /* that really shouldn't happen... */
@@ -266,7 +277,7 @@
#if HAVE_TM_ZONE
size += strlen(ta->tm_zone);
#elif HAVE_TZNAME
- size += strlen(tzname[0]);
+ size += strlen(tname[0]);
#endif
break;
case 'Z': /* timezone offset in seconds */
@@ -439,7 +450,7 @@
#if HAVE_TM_GMTOFF
sprintf(tmp_buff, "%c%02d%02d", (ta->tm_gmtoff < 0) ? '-' :
'+', abs(ta->tm_gmtoff / 3600), abs( ta->tm_gmtoff % 3600));
#else
- sprintf(tmp_buff, "%c%02d%02d", ((ta->tm_isdst ? timezone -
3600:timezone)>0)?'-':'+', abs((ta->tm_isdst ? timezone - 3600 : timezone)
/ 3600), abs((ta->tm_isdst ? timezone - 3600 : timezone) % 3600));
+ sprintf(tmp_buff, "%c%02d%02d", ((ta->tm_isdst ? tzone -
3600:tzone)>0)?'-':'+', abs((ta->tm_isdst ? tzone - 3600 : tzone) / 3600),
abs((ta->tm_isdst ? tzone - 3600 : tzone) % 3600));
#endif
strcat(Z_STRVAL_P(return_value), tmp_buff);
break;
@@ -447,7 +458,7 @@
#if HAVE_TM_GMTOFF
sprintf(tmp_buff, "%ld", ta->tm_gmtoff);
#else
- sprintf(tmp_buff, "%ld", ta->tm_isdst ? -(timezone - 3600) : -timezone);
+ sprintf(tmp_buff, "%ld", ta->tm_isdst ? -(tzone- 3600) : -tzone);
#endif
strcat(Z_STRVAL_P(return_value), tmp_buff);
break;
@@ -459,7 +470,7 @@
#if HAVE_TM_ZONE
strcat(Z_STRVAL_P(return_value), ta->tm_zone);
#elif HAVE_TZNAME
- strcat(Z_STRVAL_P(return_value), tzname[0]);
+ strcat(Z_STRVAL_P(return_value), tname[0]);
#endif
break;
case 'B': /* Swatch Beat a.k.a. Internet Time */
@@ -499,9 +510,9 @@
ta->tm_hour,
ta->tm_min,
ta->tm_sec,
- ((ta->tm_isdst ? timezone - 3600 : timezone) > 0) ? '-' : '+',
- abs((ta->tm_isdst ? timezone - 3600 : timezone) / 3600),
- abs((ta->tm_isdst ? timezone - 3600 : timezone) % 3600)
+ ((ta->tm_isdst ? tzone - 3600 : tzone) > 0) ? '-' : '+',
+ abs((ta->tm_isdst ? tzone - 3600 : tzone) / 3600),
+ abs((ta->tm_isdst ? tzone - 3600 : tzone) % 3600)
);
#endif
strcat(Z_STRVAL_P(return_value), tmp_buff);