rtsp: weekday and month names in RTSP date string should be in C locale
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 4 May 2010 14:32:59 +0000 (15:32 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 5 May 2010 12:04:25 +0000 (13:04 +0100)
Create date string using C locale weekday and month names.

Fixes #617636.

gst-libs/gst/rtsp/gstrtspconnection.c

index 18f8389..7bd1195 100644 (file)
@@ -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