void _php3_mktime(INTERNAL_FUNCTION_PARAMETERS, int gm)
{
pval *arguments[7];
- struct tm *ta;
+ struct tm *ta, tmbuf;
time_t t;
int i, gmadjust, seconds, arg_count = ARG_COUNT(ht);
** default parameters for PHP gmmktime would be the current
** GMT time values...
*/
- ta = localtime(&t);
+ ta = localtime_r(&t, &tmbuf);
/* Let DST be unknown. mktime() should compute the right value
** and behave correctly. Unless the user overrides this.
{
pval *format, *timestamp;
time_t the_time;
- struct tm *ta;
+ struct tm *ta, tmbuf;
int i, size = 0, length, h, beat;
char tmp_buff[16];
convert_to_string(format);
if (gm) {
- ta = gmtime(&the_time);
+ ta = gmtime_r(&the_time, &tmbuf);
} else {
- ta = localtime(&the_time);
+ ta = localtime_r(&the_time, &tmbuf);
}
if (!ta) { /* that really shouldn't happen... */
PHP_FUNCTION(getdate)
{
pval *timestamp_arg;
- struct tm *ta;
+ struct tm *ta, tmbuf;
time_t timestamp;
if (ARG_COUNT(ht) == 0) {
timestamp = timestamp_arg->value.lval;
}
- ta = localtime(×tamp);
+ ta = localtime_r(×tamp, &tmbuf);
if (!ta) {
php_error(E_WARNING, "Cannot perform date calculation");
return;
/* Return date string in standard format for http headers */
char *php3_std_date(time_t t)
{
- struct tm *tm1;
+ struct tm *tm1, tmbuf;
char *str;
PLS_FETCH();
- tm1 = gmtime(&t);
+ tm1 = gmtime_r(&t, &tmbuf);
str = emalloc(81);
if (PG(y2k_compliance)) {
snprintf(str, 80, "%s, %02d-%s-%04d %02d:%02d:%02d GMT",
pval *format_arg, *timestamp_arg;
char *format,*buf;
time_t timestamp;
- struct tm *ta;
+ struct tm *ta, tmbuf;
int max_reallocs = 5;
size_t buf_len=64, real_len;
RETURN_FALSE;
}
format = format_arg->value.str.val;
- ta = localtime(×tamp);
+ ta = localtime_r(×tamp, &tmbuf);
buf = (char *) emalloc(buf_len);
while ((real_len=strftime(buf,buf_len,format,ta))==buf_len || real_len==0) {