]> spindle.queued.net Git - midori/commitdiff
Print the cookie expiration date in the user's locale.
authorEnrico Tröger <enrico.troeger@uvena.de>
Mon, 30 Mar 2009 21:14:09 +0000 (23:14 +0200)
committerChristian Dywan <christian@twotoasts.de>
Mon, 30 Mar 2009 21:14:09 +0000 (23:14 +0200)
extensions/cookie-manager.c

index cbadd4e13dad5d74fec1b8adbcaa0a39ba9930be..af482a22b9126cb858e86e6feaf965e81bb882e7 100644 (file)
@@ -10,6 +10,7 @@
 */
 
 #include "config.h"
+#include <time.h>
 #include <midori/midori.h>
 #include <webkit/webkit.h>
 
@@ -143,14 +144,25 @@ static void cm_refresh_store(CMData *cmdata)
 
 static gchar *cm_get_cookie_description_text(SoupCookie *cookie)
 {
+       static gchar date_fmt[512];
        gchar *expires;
        gchar *text;
+       time_t expiration_time;
+       const struct tm *tm;
 
        g_return_val_if_fail(cookie != NULL, NULL);
 
-       expires = (cookie->expires != NULL) ?
-               soup_date_to_string(cookie->expires, SOUP_DATE_HTTP) :
-               g_strdup(_("At theend of the session"));
+       if (cookie->expires != NULL)
+       {
+               expiration_time = soup_date_to_time_t(cookie->expires);
+               tm = localtime(&expiration_time);
+               /* even if some gcc versions complain about "%c", there is nothing wrong with and here we
+                * want to use it */
+               strftime(date_fmt, sizeof(date_fmt), "%c", tm);
+               expires = date_fmt;
+       }
+       else
+               expires = _("At the end of the session");
 
        text = g_markup_printf_escaped(
                        _("<b>Host: %s</b>\n<b>Name: %s</b>\nValue: %s\nPath: %s\nSecure: %s\nExpires: %s"),
@@ -161,8 +173,6 @@ static gchar *cm_get_cookie_description_text(SoupCookie *cookie)
                        cookie->secure ? _("Yes") : _("No"),
                        expires);
 
-       g_free(expires);
-
        return text;
 }