{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);
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)) {
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 */
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++;
}
}
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];