summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Elkins <me@sigpipe.org>2010-08-06 11:45:18 -0700
committerMichael Elkins <me@sigpipe.org>2010-08-06 11:45:18 -0700
commitb8d4ddc4b2768600207e0076618da869b69df60e (patch)
tree2b79f3fe733e26dc7f2e4e48abc5f191223cfb99
parent299de0b3590c0a3bfecec9338bfb02e3117304fd (diff)
add %D format string to $folder_format to expand the time based on $date_format.
properly set the locale for LC_TIME prior to calling strftime() closes #1734 closes #3406
-rw-r--r--browser.c20
-rw-r--r--init.h1
2 files changed, 19 insertions, 2 deletions
diff --git a/browser.c b/browser.c
index d617ee5d..1a59b3f4 100644
--- a/browser.c
+++ b/browser.c
@@ -162,11 +162,27 @@ folder_format_str (char *dest, size_t destlen, size_t col, char op, const char *
break;
case 'd':
+ case 'D':
if (folder->ff->st != NULL)
{
- tnow = time (NULL);
- t_fmt = tnow - folder->ff->st->st_mtime < 31536000 ? "%b %d %H:%M" : "%b %d %Y";
+ bool do_locales = true;
+
+ if (op == 'D') {
+ t_fmt = NONULL(DateFmt);
+ if (*t_fmt == '!') {
+ ++t_fmt;
+ do_locales = false;
+ }
+ } else {
+ tnow = time (NULL);
+ t_fmt = tnow - folder->ff->st->st_mtime < 31536000 ? "%b %d %H:%M" : "%b %d %Y";
+ }
+ if (do_locales)
+ setlocale(LC_TIME, NONULL (Locale)); /* use environment if $locale is not set */
+ else
+ setlocale(LC_TIME, "C");
strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->st->st_mtime));
+
mutt_format_s (dest, destlen, fmt, date);
}
else
diff --git a/init.h b/init.h
index dd0e99d9..21df2c72 100644
--- a/init.h
+++ b/init.h
@@ -759,6 +759,7 @@ struct option_t MuttVars[] = {
** .dl
** .dt %C .dd current file number
** .dt %d .dd date/time folder was last modified
+ ** .dt %D .dd date/time folder was last modified using $$date_format.
** .dt %f .dd filename (``/'' is appended to directory names,
** ``@'' to symbolic links and ``*'' to executable
** files)