cvs: /php4 php_version.h /php4/ext/standard basic_functions.c datetime.c
| From: | Andrey Zmievski | Date: | Thu, 22 Jul 1999 15:15:41 +0000 |
| Subject: | cvs: /php4 php_version.h /php4/ext/standard basic_functions.c datetime.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-2531@lists.php.net to get a copy of this message | ||
andrey Thu Jul 22 11:15:41 1999 EDT
Modified files:
/php4 php_version.h
/php4/ext/standard basic_functions.c datetime.c
Log:
-Ported all remaining date() options
-Made array_walk() work somewhat, but it's not
possible to change array values from inside the
walk function yet
Index: php4/php_version.h
diff -u php4/php_version.h:1.4 php4/php_version.h:1.5
--- php4/php_version.h:1.4 Wed Jul 21 17:56:24 1999
+++ php4/php_version.h Thu Jul 22 11:15:40 1999
@@ -1,3 +1 @@
-/* automatically generated by configure */
-/* edit configure.in.in to change version number */
-#define PHP_VERSION "4.0b2-dev"
+#define PHP_VERSION "4.0B1"
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.48 php4/ext/standard/basic_functions.c:1.49
--- php4/ext/standard/basic_functions.c:1.48 Tue Jul 20 14:03:27 1999
+++ php4/ext/standard/basic_functions.c Thu Jul 22 11:15:40 1999
@@ -1414,7 +1414,7 @@
pval retval;
CLS_FETCH();
- args[0] = (pval *)a;
+ args[0] = *((pval **)a);
call_user_function(CG(function_table), NULL, php3_array_walk_func_name, &retval, 1, args);
return 0;
Index: php4/ext/standard/datetime.c
diff -u php4/ext/standard/datetime.c:1.12 php4/ext/standard/datetime.c:1.13
--- php4/ext/standard/datetime.c:1.12 Tue Jul 20 15:11:32 1999
+++ php4/ext/standard/datetime.c Thu Jul 22 11:15:41 1999
@@ -19,7 +19,7 @@
*/
-/* $Id: datetime.c,v 1.12 1999/07/20 19:11:32 andrey Exp $ */
+/* $Id: datetime.c,v 1.13 1999/07/22 15:15:41 andrey Exp $ */
#include "php.h"
@@ -60,6 +60,8 @@
{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
};
+#define isleap(year) (((year%4) == 0 && (year%100)!=0) || (year%400)==0)
+
PHP_FUNCTION(time)
{
return_value->value.lval = (long) time(NULL);
@@ -142,7 +144,7 @@
pval *format, *timestamp;
time_t the_time;
struct tm *ta;
- int i, size = 0, length, h;
+ int i, size = 0, length, h, beat;
char tmp_buff[16];
switch(ARG_COUNT(ht)) {
@@ -181,14 +183,18 @@
break;
case 'F': /* month, textual, full */
case 'l': /* day (of the week), textual */
+ case 'T': /* timezone name */
size += 9;
break;
+ case 'Z': /* timezone offset in seconds */
+ size += 6;
+ break;
case 'Y': /* year, numeric, 4 digits */
size += 4;
break;
case 'M': /* month, textual, 3 letters */
case 'D': /* day, textual, 3 letters */
- case 'z': /* day of the year */
+ case 'z': /* day of the year, 1 to 366 */
size += 3;
break;
case 'y': /* year, numeric, 2 digits */
@@ -205,12 +211,17 @@
case 'A': /* AM/PM */
case 'a': /* am/pm */
case 'S': /* standard english suffix for the day of the month (e.g. 3rd, 2nd, etc) */
+ case 't': /* days in current month */
size += 2;
break;
case '\\':
if(i < format->value.str.len-1) {
i++;
}
+ case 'L': /* boolean for leap year */
+ case 'B': /* Swatch Beat, 3 digits */
+ size += 3;
+ break;
case 'w': /* day of the week, numeric */
default:
size++;
@@ -328,8 +339,38 @@
}
}
break;
+ case 't': /* days in current month */
+ sprintf(tmp_buff, "%2d", phpday_tab[isleap((ta->tm_year+1900))][ta->tm_mon] );
+ strcat(return_value->value.str.val, tmp_buff);
+ 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 'Z': /* timezone offset in seconds */
+#if HAVE_TM_GMTOFF
+ sprintf(tmp_buff, "%ld", ta->tm_gmtoff );
+#else
+ sprintf(tmp_buff, "%ld", timezone);
+#endif
+ strcat(return_value->value.str.val, tmp_buff);
+ break;
+ case 'L': /* boolean for leapyear */
+ sprintf(tmp_buff, "%d", (isleap((ta->tm_year+1900)) ? 1 : 0 ) );
+ strcat(return_value->value.str.val, tmp_buff);
+ break;
+ case 'T': /* timezone name */
+#if HAVE_TM_ZONE
+ strcat(return_value->value.str.val, ta->tm_zone);
+#else
+ strcat(return_value->value.str.val, tzname[0]);
+#endif
+ break;
+ case 'B': /* Swatch Beat a.k.a. Internet Time */
+ beat = (((((long)the_time)-(((long)the_time) -
+ ((((long)the_time) % 86400) + 3600))) * 10) / 864);
+ if (beat > 999) beat = 0;
+ sprintf(tmp_buff, "%03d", beat); /* SAFE */
strcat(return_value->value.str.val, tmp_buff);
break;
default: