aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/print.c
diff options
context:
space:
mode:
authorMark Felder <feld@FreeBSD.org>2015-03-17 12:40:33 +0000
committerMark Felder <feld@FreeBSD.org>2015-03-17 12:40:33 +0000
commitc2290ff6b8f08e178fe65a73d093a5941e6cae6c (patch)
treea4c8da0a730db54398244ec6db30cfe961157d4c /bin/ps/print.c
parent3e8c6d74bb723946a98cf90912738dad1a22e727 (diff)
downloadsrc-c2290ff6b8f08e178fe65a73d093a5941e6cae6c.tar.gz
src-c2290ff6b8f08e178fe65a73d093a5941e6cae6c.zip
Use 24h timestamps in the ps(1) STARTED column
The previous 12h AM/PM format was perplexing as it didn't follow the locale of the user and was a minor annoyance to FreeBSD users coming from Linux. Additionally, the man page was incorrect about the strftime format. There are three time formats that may be displayed in the STARTED column depending on the age of the process. Below is an example. For a process started at 14:30 on Monday 16 March 2015, the following formats may be used: 14:30 for process < 24h old (24h Timestamp) Mon14 for process > 24h, < 1 week old (Weekday Hour) 16Mar15 for process > 1 week old (Day Month Year) Differential Revision: https://reviews.freebsd.org/D1620 Reviewed by: brd Approved by: trasz
Notes
Notes: svn path=/head/; revision=280171
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r--bin/ps/print.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index bcd451e1fb59..40ecd07d0318 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -383,7 +383,6 @@ started(KINFO *k, VARENT *ve __unused)
{
time_t then;
struct tm *tp;
- static int use_ampm = -1;
size_t buflen = 100;
char *buf;
@@ -394,16 +393,12 @@ started(KINFO *k, VARENT *ve __unused)
if (buf == NULL)
errx(1, "malloc failed");
- if (use_ampm < 0)
- use_ampm = (*nl_langinfo(T_FMT_AMPM) != '\0');
then = k->ki_p->ki_start.tv_sec;
tp = localtime(&then);
if (now - k->ki_p->ki_start.tv_sec < 24 * 3600) {
- (void)strftime(buf, buflen,
- use_ampm ? "%l:%M%p" : "%k:%M ", tp);
+ (void)strftime(buf, buflen, "%H:%M ", tp);
} else if (now - k->ki_p->ki_start.tv_sec < 7 * 86400) {
- (void)strftime(buf, buflen,
- use_ampm ? "%a%I%p" : "%a%H ", tp);
+ (void)strftime(buf, buflen, "%a%H ", tp);
} else
(void)strftime(buf, buflen, "%e%b%y", tp);
return (buf);