From 7fee2c0fe7aeb9f743a6676bef07ed657e8025e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 4 May 2010 15:32:59 +0100 Subject: [PATCH] rtsp: weekday and month names in RTSP date string should be in C locale Create date string using C locale weekday and month names. Fixes #617636. --- gst-libs/gst/rtsp/gstrtspconnection.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 18f83890a5..7bd1195614 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -1022,20 +1022,26 @@ add_auth_header (GstRTSPConnection * conn, GstRTSPMessage * message) static void gen_date_string (gchar * date_string, guint len) { - GTimeVal tv; + static const char wkdays[7][4] = + { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + static const char months[12][4] = + { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", + "Nov", "Dec" + }; + struct tm tm; time_t t; -#ifdef HAVE_GMTIME_R - struct tm tm_; -#endif - g_get_current_time (&tv); - t = (time_t) tv.tv_sec; + time (&t); #ifdef HAVE_GMTIME_R - strftime (date_string, len, "%a, %d %b %Y %H:%M:%S GMT", gmtime_r (&t, &tm_)); + gmtime_r (&t, &tm); #else - strftime (date_string, len, "%a, %d %b %Y %H:%M:%S GMT", gmtime (&t)); + tm = *gmtime (&t); #endif + + g_snprintf (date_string, len, "%s, %02d %s %04d %02d:%02d:%02d GMT", + wkdays[tm.tm_wday], tm.tm_mday, months[tm.tm_mon], tm.tm_year + 1900, + tm.tm_hour, tm.tm_min, tm.tm_sec); } static GstRTSPResult