summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-11-14 19:04:39 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-01-07 16:57:55 +0100
commitdaa30ef3bb592cea54dbdbce0f241bab43eec5dc (patch)
treeba393a2cad8eb30705d9a8ade82386c7d05e1e11
parentad183c61a93ca0146407d314d4ae671c894f88a8 (diff)
downloadcalcurse-daa30ef3bb592cea54dbdbce0f241bab43eec5dc.tar.gz
calcurse-daa30ef3bb592cea54dbdbce0f241bab43eec5dc.zip
Fix print_date()
In print_date(date, day, ...) it is silently assumed that day is midnight (beginning) of the day to be printed. Assume only that it belongs to the day. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/utils.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/utils.c b/src/utils.c
index 7b02f12..d380926 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1593,7 +1593,10 @@ static enum format_specifier parse_fs(const char **s, char *extformat)
}
}
-/* Print a formatted date to stdout. */
+/*
+ * Print date to stdout, formatted to be displayed for day.
+ * The "day" argument may be any time belonging to that day.
+ */
static void print_date(long date, long day, const char *extformat)
{
char buf[BUFSIZ];
@@ -1601,14 +1604,14 @@ static void print_date(long date, long day, const char *extformat)
if (!strcmp(extformat, "epoch")) {
printf("%ld", date);
} else {
- time_t day_end = date_sec_change(day, 0, 1);
- time_t t = date;
+ time_t day_start = update_time_in_date(day, 0, 0);
+ time_t day_end = date_sec_change(day_start, 0, 1);
struct tm lt;
- localtime_r((time_t *) & t, &lt);
+ localtime_r((time_t *) &date, &lt);
if (extformat[0] == '\0' || !strcmp(extformat, "default")) {
- if (date >= day && date <= day_end)
+ if (date >= day_start && date <= day_end)
strftime(buf, BUFSIZ, "%H:%M", &lt);
else
strftime(buf, BUFSIZ, "..:..", &lt);