const char day[7][4] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
const char mon[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
struct buffer *temp;
- struct tm *tm;
+ struct tm tm;
int sec_frac = 0;
time_t curr_date;
/* With high numbers, the date returned can be negative, the 55 bits mask prevent this. */
curr_date = smp->data.u.sint & 0x007fffffffffffffLL;
- tm = gmtime(&curr_date);
- if (!tm)
- return 0;
+ get_gmtime(curr_date, &tm);
temp = get_trash_chunk();
if (args[1].type == ARGT_SINT && args[1].data.sint != TIME_UNIT_S) {
temp->data = snprintf(temp->area, temp->size - temp->data,
"%s, %02d %s %04d %02d:%02d:%02d.%d GMT",
- day[tm->tm_wday], tm->tm_mday, mon[tm->tm_mon],
- 1900+tm->tm_year,
- tm->tm_hour, tm->tm_min, tm->tm_sec, sec_frac);
+ day[tm.tm_wday], tm.tm_mday, mon[tm.tm_mon],
+ 1900+tm.tm_year,
+ tm.tm_hour, tm.tm_min, tm.tm_sec, sec_frac);
} else {
temp->data = snprintf(temp->area, temp->size - temp->data,
"%s, %02d %s %04d %02d:%02d:%02d GMT",
- day[tm->tm_wday], tm->tm_mday, mon[tm->tm_mon],
- 1900+tm->tm_year,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
+ day[tm.tm_wday], tm.tm_mday, mon[tm.tm_mon],
+ 1900+tm.tm_year,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
}
smp->data.u.str = *temp;
struct buffer *temp;
/* With high numbers, the date returned can be negative, the 55 bits mask prevent this. */
time_t curr_date = smp->data.u.sint & 0x007fffffffffffffLL;
- struct tm *tm;
+ struct tm tm;
/* add offset */
if (args[1].type == ARGT_SINT)
curr_date += args[1].data.sint;
- tm = localtime(&curr_date);
- if (!tm)
- return 0;
+ get_localtime(curr_date, &tm);
+
temp = get_trash_chunk();
- temp->data = strftime(temp->area, temp->size, args[0].data.str.area,
- tm);
+ temp->data = strftime(temp->area, temp->size, args[0].data.str.area, &tm);
smp->data.u.str = *temp;
smp->data.type = SMP_T_STR;
return 1;
struct buffer *temp;
/* With high numbers, the date returned can be negative, the 55 bits mask prevent this. */
time_t curr_date = smp->data.u.sint & 0x007fffffffffffffLL;
- struct tm *tm;
+ struct tm tm;
/* add offset */
if (args[1].type == ARGT_SINT)
curr_date += args[1].data.sint;
- tm = gmtime(&curr_date);
- if (!tm)
- return 0;
+ get_gmtime(curr_date, &tm);
+
temp = get_trash_chunk();
- temp->data = strftime(temp->area, temp->size, args[0].data.str.area,
- tm);
+ temp->data = strftime(temp->area, temp->size, args[0].data.str.area, &tm);
smp->data.u.str = *temp;
smp->data.type = SMP_T_STR;
return 1;