summaryrefslogtreecommitdiff
path: root/src/uptime.c
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2008-08-04 18:51:21 +0100
committerJim Meyering <meyering@redhat.com>2008-08-05 12:21:30 +0200
commit273c10fc2c508715f8810eb640d6561bf0caaabf (patch)
treed5bf7062fc31d64e5c0cc4f75fb051113713323d /src/uptime.c
parentf4bffea5e95fbb008402c156e50f81a887423250 (diff)
downloadcoreutils-273c10fc2c508715f8810eb640d6561bf0caaabf.tar.xz
Document uptime.
* doc/coreutils.texi (uptime invocation): document uptime. * TODO: uptime is documented now. * src/uptime.c (print_uptime): Use fprintftime to print the time, rather than printf. This should make the situation better for translations.
Diffstat (limited to 'src/uptime.c')
-rw-r--r--src/uptime.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/uptime.c b/src/uptime.c
index 56ad861b1..b35e97a48 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -36,6 +36,7 @@
#include "long-options.h"
#include "quote.h"
#include "readutmp.h"
+#include "fprintftime.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "uptime"
@@ -126,12 +127,10 @@ print_uptime (size_t n, const STRUCT_UTMP *this)
uphours = (uptime - (updays * 86400)) / 3600;
upmins = (uptime - (updays * 86400) - (uphours * 3600)) / 60;
tmn = localtime (&time_now);
+ /* procps' version of uptime also prints the seconds field, but
+ previous versions of coreutils don't. */
if (tmn)
- printf (_(" %2d:%02d%s up "),
- ((tmn->tm_hour % 12) == 0 ? 12 : tmn->tm_hour % 12),
- /* FIXME: use strftime, not am, pm. Uli reports that
- the german translation is meaningless. */
- tmn->tm_min, (tmn->tm_hour < 12 ? _("am") : _("pm")));
+ fprintftime (stdout, _(" %H:%M%P up "), tmn, 0, 0);
else
printf (_(" ??:???? up "));
if (uptime == (time_t) -1)
@@ -197,10 +196,21 @@ usage (int status)
printf (_("\
Print the current time, the length of time the system has been up,\n\
the number of users on the system, and the average number of jobs\n\
-in the run queue over the last 1, 5 and 15 minutes.\n\
+in the run queue over the last 1, 5 and 15 minutes."));
+#ifdef __linux__
+ /* It would be better to introduce a configure test for this,
+ but such a test is hard to write. For the moment then, we
+ have a hack which depends on the preprocessor used at compile
+ time to tell us what the running kernel is. Ugh. */
+ printf(_(" \
+Processes in\n\
+an uninterruptible sleep state also contribute to the load average.\n"));
+#else
+ printf(_("\n"));
+#endif
+ printf (_("\
If FILE is not specified, use %s. %s as FILE is common.\n\
-\n\
-"),
+\n"),
UTMP_FILE, WTMP_FILE);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);