cvs: php4 /ext/standard datetime.c
| From: | Mike Waychison | Date: | Tue, 04 Jul 2000 16:16:32 +0000 |
| Subject: | cvs: php4 /ext/standard datetime.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-616@lists.php.net to get a copy of this message | ||
mikew Tue Jul 4 09:16:32 2000 EDT
Modified files:
/php4/ext/standard datetime.c
Log:
(PHP date) Added new 'O' format modifier for printing out the GMT Offset in
the same manner as emails have in their Date: header. The format
is similar to [+-]HHMM of offset.
@- Added new 'O' format modifier that will output the GMT offset as "[+-]HHMM"
@ (eg: Pacific time is -0700). This is useful for things such as Date: mail
@ headers.
# Um, this should have existed LONG time ago... much better than that gmt
# offset in seconds modifier :)
Index: php4/ext/standard/datetime.c
diff -u php4/ext/standard/datetime.c:1.49 php4/ext/standard/datetime.c:1.50
--- php4/ext/standard/datetime.c:1.49 Sun Jun 25 10:55:13 2000
+++ php4/ext/standard/datetime.c Tue Jul 4 09:16:32 2000
@@ -19,7 +19,7 @@
*/
-/* $Id: datetime.c,v 1.49 2000/06/25 17:55:13 eschmid Exp $ */
+/* $Id: datetime.c,v 1.50 2000/07/04 16:16:32 mikew Exp $ */
#include "php.h"
@@ -236,6 +236,9 @@
}
for (i = 0; i < (*format)->value.str.len; i++) {
switch ((*format)->value.str.val[i]) {
+ case 'O': /* GMT offset in [+-]HHMM format */
+ size += 5;
+ break;
case 'U': /* seconds since the epoch */
size += 10;
break;
@@ -404,6 +407,14 @@
break;
case 'w': /* day of the week, numeric EXTENSION */
sprintf(tmp_buff, "%01d", ta->tm_wday); /* SAFE */
+ strcat(return_value->value.str.val, tmp_buff);
+ break;
+ case 'O': /* GMT offset in [+-]HHMM format */
+#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));
+#endif
strcat(return_value->value.str.val, tmp_buff);
break;
case 'Z': /* timezone offset in seconds */