From b9b2672ad86728d5fa74cc74833459ae367aec9f Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sat, 8 Oct 2011 17:31:05 +0000 Subject: [PATCH] Shorten get_http_time() by using strftime() --- cgi.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/cgi.c b/cgi.c index f04cf158..fc49f5ad 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -const char cgi_rcs[] = "$Id: cgi.c,v 1.143 2011/08/17 10:26:47 fabiankeil Exp $"; +const char cgi_rcs[] = "$Id: cgi.c,v 1.144 2011/09/04 11:10:56 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgi.c,v $ @@ -1395,12 +1395,6 @@ char *add_help_link(const char *item, *********************************************************************/ void get_http_time(int time_offset, char *buf, size_t buffer_size) { - static const char day_names[7][4] = - { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; - static const char month_names[12][4] = - { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - struct tm *t; time_t current_time; #if defined(HAVE_GMTIME_R) @@ -1425,17 +1419,7 @@ void get_http_time(int time_offset, char *buf, size_t buffer_size) t = gmtime(¤t_time); #endif - /* Format: "Sun, 06 Nov 1994 08:49:37 GMT" */ - snprintf(buf, buffer_size, - "%s, %02d %s %4d %02d:%02d:%02d GMT", - day_names[t->tm_wday], - t->tm_mday, - month_names[t->tm_mon], - t->tm_year + 1900, - t->tm_hour, - t->tm_min, - t->tm_sec - ); + strftime(buf, buffer_size, "%a, %d %b %Y %H:%M:%S GMT", t); } -- 2.39.2