]> git.saurik.com Git - apt.git/commitdiff
use de-localed std::put_time instead rolling our own
authorDavid Kalnischkies <david@kalnischkies.de>
Sat, 28 May 2016 10:55:21 +0000 (12:55 +0200)
committerJulian Andres Klode <jak@debian.org>
Mon, 14 Nov 2016 14:10:03 +0000 (15:10 +0100)
(cherry picked from commit eceb219c2a64f3f81421c3c6587380b6ae81a530)

apt-pkg/contrib/strutl.cc

index 26e303263deb6c21cbd08729ef6d4a5697bbdbbe..9b7162e3ef193446884f51ec07b632977aece5c5 100644 (file)
@@ -751,15 +751,11 @@ string TimeRFC1123(time_t Date)
    if (gmtime_r(&Date, &Conv) == NULL)
       return "";
 
    if (gmtime_r(&Date, &Conv) == NULL)
       return "";
 
-   char Buf[300];
-   const char *Day[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
-   const char *Month[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul",
-                          "Aug","Sep","Oct","Nov","Dec"};
-
-   snprintf(Buf, sizeof(Buf), "%s, %02i %s %i %02i:%02i:%02i GMT",Day[Conv.tm_wday],
-          Conv.tm_mday,Month[Conv.tm_mon],Conv.tm_year+1900,Conv.tm_hour,
-          Conv.tm_min,Conv.tm_sec);
-   return Buf;
+   auto const posix = std::locale("C.UTF-8");
+   std::ostringstream datestr;
+   datestr.imbue(posix);
+   datestr << std::put_time(&Conv, "%a, %d %b %Y %H:%M:%S GMT");
+   return datestr.str();
 }
                                                                        /*}}}*/
 // ReadMessages - Read messages from the FD                            /*{{{*/
 }
                                                                        /*}}}*/
 // ReadMessages - Read messages from the FD                            /*{{{*/