Questa index_formatvariabile
set index_format='mfdate "%[%s]" "%4C %Z %[!%b %d %Y] %-17.17F (%3l) %s" |'
insieme a questo modificato mfdate.cpresentato in questa risposta dall'utente hop :
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define DAY (time_t)86400
#define YEAR (time_t)31556926
int main(int argc, const char *argv[]) {
time_t current_time;
time_t message_time;
const char *old = "old";
char *recent = "recent";
char *today = "today";
const char *format;
current_time = time(NULL);
if (argc != 3) {
printf("Usage: %s format\n", argv[0]);
return EXIT_FAILURE;
}
format = argv[2];
message_time = atoi(argv[1]);
if ((message_time/YEAR) < (current_time/YEAR)) {
printf("%s,%s", old, format);
} else if ((message_time/DAY) < (current_time/DAY)) {
printf("%s,%s", recent, format);
} else {
printf("%s,%s", today, format);
}
return EXIT_SUCCESS;
}
funziona correttamente per me in mutt 1.6.1e come vedi non ci sono problemi con il %segno nell'oggetto, se questo è il vero problema:
Questa è la versione iniziale "funzionante" perché dopo aver dato un'occhiata più da vicino alla tua domanda originale non sono sicuro che questo sia ciò che desideri. Tuttavia, se questo è quello che vuoi, fammi sapere e penseremo come migliorarlo.
MODIFICA :
Può anche funzionare con il tuo preferito index_format:
set index_format='mfdate "%[%s]" "%%Z %%{%%Y %%b %%e %%H:%%M} %%?X?(%%X)& ? %%-22.22F %%.100s %%> %%5c" |'
mfdate.c:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#define DAY (time_t)86400
#define YEAR (time_t)31556926
int main(int argc, const char *argv[]) {
time_t current_time;
time_t message_time;
const char *old = "old";
char *recent = "recent";
char *today = "today";
const char *format;
current_time = time(NULL);
if (argc != 3) {
printf("Usage: %s format\n", argv[0]);
return EXIT_FAILURE;
}
format = argv[2];
message_time = atoi(argv[1]);
if ((message_time/YEAR) < (current_time/YEAR)) {
printf("%s,%s%%", old, format);
} else if ((message_time/DAY) < (current_time/DAY)) {
printf("%s,%s%%", recent, format);
} else {
printf("%s,%s%%", today, format);
}
return 0;
}

MODIFICA :
Lasciami spiegare come funziona:
Ci mfdatevogliono 2 argomenti:
"%[%s]"
e:
"%%Z %%{%%Y %%b %%e %%H:%%M} %%?X?(%%X)& ? %%-22.22F %%.100s %%> %%5c"
Il primo argomento è solo time of the message, come descritto nella
index_formatdocumentazione in .muttrc:
# %[fmt] the date and time of the message is converted to the local
# time zone, and ``fmt'' is expanded by the library function
# ``strftime''; a leading bang disables locales
In questo caso fmtviene sostituito con %s, perché come %smezzi The
number of seconds since the Epochcome spiegato in man strftime. Il primo argomento è utilizzato per calcolare quanti anni il messaggio è e ciò che l'etichetta: old, recento todaydovrebbe avere.
Il secondo argomento è la parte rimanente della index_format
variabile. È usato mfdatesolo per la stampa ma %alla fine di questo viene aggiunto un extra printfperché, come dice il manuale di mutt :
La stringa restituita verrà utilizzata per la visualizzazione. Se la stringa restituita termina in%, verrà passata attraverso il formatter una seconda volta.
Tutto %è raddoppiato qui perché vogliamo passare letteralmente %alla seconda formattazione effettuata da mutt.