summaryrefslogtreecommitdiffstats
path: root/format.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2022-06-21 12:01:09 +0100
committerThomas Adam <thomas@xteddy.org>2022-06-21 12:01:09 +0100
commitb63afaea61c8076610a6003d4d046a95436460cf (patch)
treeec3188d61816904f74b9859d583634b380a25588 /format.c
parentd46870ede5e79c748cf8d06a00cdcc7310846844 (diff)
parent9c89f7c2af748858e784e8c533c548460bd6b10e (diff)
Merge branch 'obsd-master'
Diffstat (limited to 'format.c')
-rw-r--r--format.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/format.c b/format.c
index ccd259ec..915adfff 100644
--- a/format.c
+++ b/format.c
@@ -3387,12 +3387,12 @@ format_quote_style(const char *s)
}
/* Make a prettier time. */
-static char *
-format_pretty_time(time_t t)
+char *
+format_pretty_time(time_t t, int seconds)
{
struct tm now_tm, tm;
time_t now, age;
- char s[6];
+ char s[9];
time(&now);
if (now < t)
@@ -3404,7 +3404,10 @@ format_pretty_time(time_t t)
/* Last 24 hours. */
if (age < 24 * 3600) {
- strftime(s, sizeof s, "%H:%M", &tm);
+ if (seconds)
+ strftime(s, sizeof s, "%H:%M:%S", &tm);
+ else
+ strftime(s, sizeof s, "%H:%M", &tm);
return (xstrdup(s));
}
@@ -3509,7 +3512,7 @@ found:
if (t == 0)
return (NULL);
if (modifiers & FORMAT_PRETTY)
- found = format_pretty_time(t);
+ found = format_pretty_time(t, 0);
else {
if (time_format != NULL) {
localtime_r(&t, &tm);