msgview: add separate date formatting

The ThisDayTimeFormat and friends are missing from the message view
which just uses the message list's default setting. This might not be
desirable since the amount of space available is different. Introduce
separate settings for formatting dates in the message view.

Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Bence Ferdinandy 2022-10-19 13:21:41 +02:00 committed by Robin Jarry
parent 6eed15c579
commit c3bb3aa2a8
4 changed files with 101 additions and 47 deletions
lib/format

View file

@ -178,7 +178,7 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
}
retval = append(retval, 's')
args = append(args,
dummyIfZeroDate(date.Local(),
DummyIfZeroDate(date.Local(),
timeFmt, thisDayTimeFmt,
thisWeekTimeFmt, thisYearTimeFmt))
case 'D':
@ -188,7 +188,7 @@ func ParseMessageFormat(format string, timeFmt string, thisDayTimeFmt string,
}
retval = append(retval, 's')
args = append(args,
dummyIfZeroDate(date.Local(),
DummyIfZeroDate(date.Local(),
timeFmt, thisDayTimeFmt,
thisWeekTimeFmt, thisYearTimeFmt))
case 'f':
@ -395,7 +395,7 @@ handle_end_error:
errors.New("reached end of string while parsing message format")
}
func dummyIfZeroDate(date time.Time, format string, todayFormat string,
func DummyIfZeroDate(date time.Time, format string, todayFormat string,
thisWeekFormat string, thisYearFormat string,
) string {
if date.IsZero() {