[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
uptime: addressing FIXME issue
From: |
Tobias Stöckmann |
Subject: |
uptime: addressing FIXME issue |
Date: |
Mon, 23 Jun 2003 19:50:02 +0200 |
FIXME: use strftime, not am, pm. Uli reports that
the german translation is meaningless.
I've changed the printf-function to strftime.
Before strftime can be called, the locale has to be set
to C, because some locales can't handle %P.
Also this patch changes
time_now = time (0);
to
time_now = time (NULL);
as it's done in other programs, too.
Hope this helps.
----
uptime patch follow:
--- uptime.orig.c 2003-06-17 20:13:24.000000000 +0200
+++ uptime.c 2003-06-23 19:32:21.000000000 +0200
@@ -61,6 +61,7 @@
struct tm *tmn;
double avg[3];
int loads;
+ char buffer[14];
#ifdef HAVE_PROC_UPTIME
FILE *fp;
double upsecs;
@@ -120,7 +121,7 @@
#endif /* BOOT_MSG */
++this;
}
- time_now = time (0);
+ time_now = time (NULL);
#if defined HAVE_PROC_UPTIME
if (uptime == 0)
#endif
@@ -133,11 +134,10 @@
uphours = (uptime - (updays * 86400)) / 3600;
upmins = (uptime - (updays * 86400) - (uphours * 3600)) / 60;
tmn = localtime (&time_now);
- 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")));
+ setlocale (LC_ALL, "C");
+ strftime (buffer, 14, " %l:%M%P up ", tmn);
+ fputs (buffer, stdout);
+ setlocale (LC_ALL, "");
if (updays > 0)
printf (ngettext("%d day", "%d days", updays), updays);
printf (" %2d:%02d, ", uphours, upmins);
____________________________________________________________________________
Jetzt bei WEB.DE FreeMail anmelden = 1qm Regenwald schuetzen! Helfen
Sie mit! Nutzen Sie den Serien-Testsieger. http://user.web.de/Regenwald
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- uptime: addressing FIXME issue,
Tobias Stöckmann <=