about summary refs log tree commit diff
path: root/mscan.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-05-21 01:07:20 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-05-21 01:07:47 +0200
commit3732dd355dce17c54c47d51c16da4318774bf9e3 (patch)
treeddf61aeaeb1c503cdf83e5e217d39ce944e59858 /mscan.c
parent4f99861f091d0f2bfb3eae23220955a95e42d1f0 (diff)
downloadmblaze-3732dd355dce17c54c47d51c16da4318774bf9e3.tar.gz
mblaze-3732dd355dce17c54c47d51c16da4318774bf9e3.tar.xz
mblaze-3732dd355dce17c54c47d51c16da4318774bf9e3.zip
mscan: use %H:%M timestamp for all mails newer than 24h
Diffstat (limited to 'mscan.c')
-rw-r--r--mscan.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/mscan.c b/mscan.c
index d6607f3..9264587 100644
--- a/mscan.c
+++ b/mscan.c
@@ -29,7 +29,7 @@ static int alias_idx;
 static int Iflag;
 static int nflag;
 static int curyear;
-static int curyday;
+static time_t now;
 static char default_fflag[] = "%c%u%r %-3n %10d %17f %t %2i%s";
 static char *fflag = default_fflag;
 
@@ -137,14 +137,14 @@ fmt_date(struct message *msg, int w, int iso)
 	} else if (w < 10) {
 		if (tm->tm_year != curyear)
 			strftime(date, sizeof date, "%b%y", tm);
-		else if (tm->tm_yday != curyday)
+		else if (t > now || now - t > 86400)
 			strftime(date, sizeof date, "%d%b", tm);
 		else
 			strftime(date, sizeof date, "%H:%M", tm);
 	} else {
 		if (tm->tm_year != curyear)
 			strftime(date, sizeof date, "%Y-%m-%d", tm);
-		else if (tm->tm_yday != curyday)
+		else if (t > now || now - t > 86400)
 			strftime(date, sizeof date, "%a %b %e", tm);
 		else
 			strftime(date, sizeof date, "%a  %H:%M", tm);
@@ -507,10 +507,9 @@ main(int argc, char *argv[])
 		return 0;
 	}
 
-	time_t now = time(0);
+	now = time(0);
 	struct tm *tm = localtime(&now);
 	curyear = tm->tm_year;
-	curyday = tm->tm_yday;
 
 	setlocale(LC_ALL, "");	// for wcwidth later
 	if (wcwidth(0xfffd) > 0)