From: Enrico Tröger Date: Mon, 30 Mar 2009 21:14:09 +0000 (+0200) Subject: Print the cookie expiration date in the user's locale. X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe53c0b7035837311ca76b0f2e6dfb890dc30425;p=midori Print the cookie expiration date in the user's locale. --- diff --git a/extensions/cookie-manager.c b/extensions/cookie-manager.c index cbadd4e1..af482a22 100644 --- a/extensions/cookie-manager.c +++ b/extensions/cookie-manager.c @@ -10,6 +10,7 @@ */ #include "config.h" +#include #include #include @@ -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( _("Host: %s\nName: %s\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; }