mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 10:58:10 +01:00
Fix relative date formatting to not split one day into two formats.
We were aware of this bug when we wrote the function, (that a date six days in the past would be treated as the "Friday" or as the "Oct. 23" case depending on whether its time was before or after the current time today). We thought it wouldn't be a problem, but in practice it is. In scanning search results with this output, the transition between formats makes it look like a day boundary, (so it would be easy to mistakenly think "Oct. 23" is Thursday). Fix this to avoid confusion, (still being careful to never print "Thursday" for a date 7 days in the past when today is Thursday).
This commit is contained in:
parent
c771eaf362
commit
a2f0445e1b
1 changed files with 9 additions and 7 deletions
12
notmuch.c
12
notmuch.c
|
@ -770,7 +770,7 @@ _format_relative_date (void *ctx, time_t then)
|
||||||
|
|
||||||
if (delta > 180 * DAY) {
|
if (delta > 180 * DAY) {
|
||||||
strftime (result, RELATIVE_DATE_MAX,
|
strftime (result, RELATIVE_DATE_MAX,
|
||||||
"%F", &tm_then);
|
"%F", &tm_then); /* 2008-06-30 */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,24 +780,26 @@ _format_relative_date (void *ctx, time_t then)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta <= 6 * DAY) {
|
if (delta <= 7 * DAY) {
|
||||||
if (tm_then.tm_wday == tm_now.tm_wday &&
|
if (tm_then.tm_wday == tm_now.tm_wday &&
|
||||||
delta < DAY)
|
delta < DAY)
|
||||||
{
|
{
|
||||||
strftime (result, RELATIVE_DATE_MAX,
|
strftime (result, RELATIVE_DATE_MAX,
|
||||||
"%R", &tm_then);
|
"%R", &tm_then); /* 12:30 */
|
||||||
return result;
|
return result;
|
||||||
} else if ((tm_now.tm_wday + 7 - tm_then.tm_wday) % 7 == 1) {
|
} else if ((tm_now.tm_wday + 7 - tm_then.tm_wday) % 7 == 1) {
|
||||||
return "Yesterday";
|
return "Yesterday";
|
||||||
} else {
|
} else {
|
||||||
|
if (tm_then.tm_wday != tm_now.tm_wday) {
|
||||||
strftime (result, RELATIVE_DATE_MAX,
|
strftime (result, RELATIVE_DATE_MAX,
|
||||||
"%A", &tm_then);
|
"%A", &tm_then); /* Monday */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
strftime (result, RELATIVE_DATE_MAX,
|
strftime (result, RELATIVE_DATE_MAX,
|
||||||
"%b %d", &tm_then);
|
"%b %d", &tm_then); /* Oct. 12 */
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#undef MINUTE
|
#undef MINUTE
|
||||||
|
|
Loading…
Reference in a new issue