version 1.304, 2022/05/30 13:07:06 |
version 1.305, 2022/06/21 09:30:01 |
|
|
} |
} |
|
|
/* Make a prettier time. */ |
/* Make a prettier time. */ |
static char * |
char * |
format_pretty_time(time_t t) |
format_pretty_time(time_t t, int seconds) |
{ |
{ |
struct tm now_tm, tm; |
struct tm now_tm, tm; |
time_t now, age; |
time_t now, age; |
char s[6]; |
char s[9]; |
|
|
time(&now); |
time(&now); |
if (now < t) |
if (now < t) |
|
|
|
|
/* Last 24 hours. */ |
/* Last 24 hours. */ |
if (age < 24 * 3600) { |
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)); |
return (xstrdup(s)); |
} |
} |
|
|
|
|
if (t == 0) |
if (t == 0) |
return (NULL); |
return (NULL); |
if (modifiers & FORMAT_PRETTY) |
if (modifiers & FORMAT_PRETTY) |
found = format_pretty_time(t); |
found = format_pretty_time(t, 0); |
else { |
else { |
if (time_format != NULL) { |
if (time_format != NULL) { |
localtime_r(&t, &tm); |
localtime_r(&t, &tm); |