tony2001 Thu Jun 22 21:04:32 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/date php_date.c
Log:
MFH: add wrappers for timelib_day_of_week_ex()
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.10&r2=1.43.2.45.2.11&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.10
php-src/ext/date/php_date.c:1.43.2.45.2.11
--- php-src/ext/date/php_date.c:1.43.2.45.2.10 Thu Jun 22 18:44:31 2006
+++ php-src/ext/date/php_date.c Thu Jun 22 21:04:32 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.45.2.10 2006/06/22 18:44:31 tony2001 Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.11 2006/06/22 21:04:32 tony2001 Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -670,6 +670,26 @@
}
/* }}} */
+/* {{{ day of week helpers */
+char *php_date_full_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
+{
+ timelib_sll day_of_week = timelib_day_of_week(y, m, d);
+ if (day_of_week < 0) {
+ return "Unknown";
+ }
+ return day_full_names[day_of_week];
+}
+
+char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib_sll d)
+{
+ timelib_sll day_of_week = timelib_day_of_week(y, m, d);
+ if (day_of_week < 0) {
+ return "Unknown";
+ }
+ return day_short_names[day_of_week];
+}
+/* }}} */
+
/* {{{ date_format - (gm)date helper */
static char *date_format(char *format, int format_len, timelib_time *t, int
localtime)
{
@@ -712,9 +732,9 @@
switch (format[i]) {
/* day */
case 'd': snprintf(buffer, 32, "%02d", (int) t->d);
break;
- case 'D': snprintf(buffer, 32, "%s",
day_short_names[timelib_day_of_week(t->y, t->m, t->d)]); break;
+ case 'D': snprintf(buffer, 32, "%s",
php_date_short_day_name(t->y, t->m, t->d)); break;
case 'j': snprintf(buffer, 32, "%d", (int) t->d); break;
- case 'l': snprintf(buffer, 32, "%s",
day_full_names[timelib_day_of_week(t->y, t->m, t->d)]); break;
+ case 'l': snprintf(buffer, 32, "%s",
php_date_full_day_name(t->y, t->m, t->d)); break;
case 'S': snprintf(buffer, 32, "%s",
english_suffix(t->d)); break;
case 'w': snprintf(buffer, 32, "%d", (int)
timelib_day_of_week(t->y, t->m, t->d)); break;
case 'N': snprintf(buffer, 32, "%d", (int)
timelib_iso_day_of_week(t->y, t->m, t->d)); break;
@@ -779,7 +799,7 @@
);
break;
case 'r': snprintf(buffer, 32, "%3s, %02d %3s %04d
%02d:%02d:%02d %c%02d%02d",
-
day_short_names[timelib_day_of_week(t->y, t->m, t->d)],
+
php_date_short_day_name(t->y, t->m, t->d),
(int) t->d, mon_short_names[t->m - 1],
(int) t->y, (int) t->h, (int) t->i, (int) t->s,
localtime ? ((offset->offset < 0) ? '-' : '+') : '+',
@@ -1405,7 +1425,7 @@
add_assoc_long(return_value, "mon", ts->m);
add_assoc_long(return_value, "year", ts->y);
add_assoc_long(return_value, "yday", timelib_day_of_year(ts->y, ts->m,
ts->d));
- add_assoc_string(return_value, "weekday",
day_full_names[timelib_day_of_week(ts->y, ts->m, ts->d)], 1);
+ add_assoc_string(return_value, "weekday", php_date_full_day_name(ts->y,
ts->m, ts->d), 1);
add_assoc_string(return_value, "month", mon_full_names[ts->m - 1], 1);
add_index_long(return_value, 0, timestamp);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php