diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/http.c | 7 | ||||
-rw-r--r-- | src/libutil/logger.c | 6 | ||||
-rw-r--r-- | src/libutil/util.c | 10 | ||||
-rw-r--r-- | src/libutil/util.h | 4 |
4 files changed, 15 insertions, 12 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index 9e3e2f2a1..5732f8b8e 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1745,15 +1745,14 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted, { gchar datebuf[64]; gint meth_len = 0; - struct tm t, *ptm; + struct tm t; if (conn->type == RSPAMD_HTTP_SERVER) { /* Format reply */ if (msg->method < HTTP_SYMBOLS) { rspamd_ftok_t status; - ptm = gmtime (&msg->date); - t = *ptm; + rspamd_gmtime (msg->date, &t); rspamd_snprintf (datebuf, sizeof(datebuf), "%s, %02d %s %4d %02d:%02d:%02d GMT", http_week[t.tm_wday], t.tm_mday, http_month[t.tm_mon], t.tm_year + 1900, @@ -3689,7 +3688,7 @@ rspamd_http_date_format (gchar *buf, gsize len, time_t time) { struct tm tms; - tms = *gmtime (&time); + rspamd_gmtime (time, &tms); return rspamd_snprintf (buf, len, "%s, %02d %s %4d %02d:%02d:%02d GMT", http_week[tms.tm_wday], tms.tm_mday, diff --git a/src/libutil/logger.c b/src/libutil/logger.c index 1fade8164..6b83ddb05 100644 --- a/src/libutil/logger.c +++ b/src/libutil/logger.c @@ -866,7 +866,7 @@ file_log_function (const gchar *module, const gchar *id, static gchar tmpbuf[256], timebuf[64], modulebuf[64]; gchar *m; gdouble now; - struct tm *tms; + struct tm tms; struct iovec iov[5]; gulong r = 0, mr = 0; guint64 cksum; @@ -1011,8 +1011,8 @@ file_log_function (const gchar *module, const gchar *id, time_t sec = now; gsize r; - tms = localtime (&sec); - r = strftime (timebuf, sizeof (timebuf), "%F %H:%M:%S", tms); + rspamd_localtime (sec, &tms); + r = strftime (timebuf, sizeof (timebuf), "%F %H:%M:%S", &tms); if (rspamd_log->flags & RSPAMD_LOG_FLAG_USEC) { gchar usec_buf[16]; diff --git a/src/libutil/util.c b/src/libutil/util.c index bf18d8fc4..5e271ed80 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -2669,7 +2669,7 @@ rspamd_tm_to_time (const struct tm *tm, glong tz) void -rspamd_gmtime (guint64 ts, struct tm *dest) +rspamd_gmtime (gint64 ts, struct tm *dest) { guint64 days, secs, years; int remdays, remsecs, remyears; @@ -2756,7 +2756,9 @@ rspamd_gmtime (guint64 ts, struct tm *dest) dest->tm_hour = remsecs / 3600; dest->tm_min = remsecs / 60 % 60; dest->tm_sec = remsecs % 60; +#if !defined(__sun) dest->tm_gmtoff = 0; +#endif dest->tm_zone = "GMT"; } @@ -2764,9 +2766,9 @@ extern char *tzname[2]; extern long timezone; extern int daylight; -void rspamd_localtime (guint64 ts, struct tm *dest) +void rspamd_localtime (gint64 ts, struct tm *dest) { - static guint64 last_tzcheck = 0; + static gint64 last_tzcheck = 0; static const guint tz_check_interval = 120; if (ts - last_tzcheck > tz_check_interval) { @@ -2777,7 +2779,9 @@ void rspamd_localtime (guint64 ts, struct tm *dest) ts += timezone; rspamd_gmtime (ts, dest); dest->tm_zone = daylight ? (tzname[1] ? tzname[1] : tzname[0]) : tzname[0]; +#if !defined(__sun) dest->tm_gmtoff = timezone; +#endif } gboolean diff --git a/src/libutil/util.h b/src/libutil/util.h index 03399fec3..6470b5c45 100644 --- a/src/libutil/util.h +++ b/src/libutil/util.h @@ -479,14 +479,14 @@ guint64 rspamd_tm_to_time (const struct tm *tm, glong tz); * @param ts * @param dest */ -void rspamd_gmtime (guint64 ts, struct tm *dest); +void rspamd_gmtime (gint64 ts, struct tm *dest); /** * Split unix timestamp into struct tm using local timezone * @param ts * @param dest */ -void rspamd_localtime (guint64 ts, struct tm *dest); +void rspamd_localtime (gint64 ts, struct tm *dest); #define PTR_ARRAY_FOREACH(ar, i, cur) for ((i) = 0; (ar) != NULL && (i) < (ar)->len && (((cur) = g_ptr_array_index((ar), (i))) || 1); ++(i)) |