print_datediff(): Actually print a date difference

Instead of passing a date and printing the date difference between that
date and the current date, pass an actual date difference. This allows
for using the function in other places, such as for printing item
durations.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2013-07-17 13:55:42 +02:00
parent 18b6e360b8
commit ae93db284e

View File

@ -1238,15 +1238,12 @@ static void print_date(long date, long day, const char *extformat)
} }
/* Print a time difference to stdout. */ /* Print a time difference to stdout. */
static void print_datediff(long date, const char *extformat) static void print_datediff(long difference, const char *extformat)
{ {
const char *p; const char *p;
const char *numfmt; const char *numfmt;
bool usetotal; bool usetotal;
long value; long value;
time_t difference;
difference = difftime(date, now());
if (!strcmp(extformat, "epoch")) { if (!strcmp(extformat, "epoch")) {
printf("%ld", difference); printf("%ld", difference);
@ -1335,7 +1332,8 @@ void print_apoint(const char *format, long day, struct apoint *apt)
extformat); extformat);
break; break;
case FS_REMAINING: case FS_REMAINING:
print_datediff(apt->start, extformat); print_datediff(difftime(apt->start, now()),
extformat);
break; break;
case FS_MESSAGE: case FS_MESSAGE:
printf("%s", apt->mesg); printf("%s", apt->mesg);