]> granicus.if.org Git - php/commitdiff
-Ported all remaining date() options
authorAndrey Hristov <andrey@php.net>
Thu, 22 Jul 1999 15:15:41 +0000 (15:15 +0000)
committerAndrey Hristov <andrey@php.net>
Thu, 22 Jul 1999 15:15:41 +0000 (15:15 +0000)
-Made array_walk() work somewhat, but it's not
 possible to change array values from inside the
 walk function yet

ext/standard/basic_functions.c
ext/standard/datetime.c
main/php_version.h

index 2a955860439e64673429e23cc38b00040201a6d0..3f445804a09de461057e8a53c0d8390e19216af9 100644 (file)
@@ -1414,7 +1414,7 @@ static int _php3_array_walk(const void *a)
        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 41f6765362b4694db3a368ece097584aa8183ad9..99038e0bd536f811d36b243410db838425504c0d 100644 (file)
@@ -60,6 +60,8 @@ static int phpday_tab[2][12] =
        {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 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
        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 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
                                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 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
                        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,10 +339,40 @@ _php3_date(INTERNAL_FUNCTION_PARAMETERS, int gm)
                                        }
                                }
                                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:
                                length = strlen(return_value->value.str.val);
                                return_value->value.str.val[length] = format->value.str.val[i];
index ab60bf6f9f5de15d110a19e91f235f76f4b93c6d..ee69a881fcbb3176fd3a29b246c4ece4d051a4fa 100644 (file)
@@ -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"