mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 09:21:18 +02:00
- dboxinfo: show uptime even more human readable
This commit is contained in:
@@ -362,32 +362,38 @@ void CDBoxInfoWidget::paint()
|
|||||||
char sbuf[buf_size];
|
char sbuf[buf_size];
|
||||||
memset(sbuf, 0, 256);
|
memset(sbuf, 0, 256);
|
||||||
|
|
||||||
int updays, uphours, upminutes;
|
|
||||||
struct sysinfo info;
|
struct sysinfo info;
|
||||||
|
sysinfo(&info);
|
||||||
|
|
||||||
|
//get uptime
|
||||||
|
#if 0
|
||||||
struct tm *current_time;
|
struct tm *current_time;
|
||||||
time_t current_secs;
|
time_t current_secs;
|
||||||
time(¤t_secs);
|
time(¤t_secs);
|
||||||
current_time = localtime(¤t_secs);
|
current_time = localtime(¤t_secs);
|
||||||
|
|
||||||
sysinfo(&info);
|
|
||||||
|
|
||||||
//get uptime
|
|
||||||
snprintf( ubuf,buf_size, "%02d:%02d%s up ",
|
snprintf( ubuf,buf_size, "%02d:%02d%s up ",
|
||||||
current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
|
current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
|
||||||
current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
|
current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
|
||||||
strcat(sbuf, ubuf);
|
strcat(sbuf, ubuf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int updays, uphours, upminutes;
|
||||||
|
|
||||||
updays = (int) info.uptime / (60*60*24);
|
updays = (int) info.uptime / (60*60*24);
|
||||||
|
upminutes = (int) info.uptime / 60;
|
||||||
|
uphours = (upminutes / 60) % 24;
|
||||||
|
upminutes %= 60;
|
||||||
|
|
||||||
if (updays) {
|
if (updays) {
|
||||||
snprintf(ubuf,buf_size, "%d day%s, ", updays, (updays != 1) ? "s" : "");
|
snprintf(ubuf,buf_size, "%d day%s, ", updays, (updays != 1) ? "s" : "");
|
||||||
strcat(sbuf, ubuf);
|
strcat(sbuf, ubuf);
|
||||||
}
|
}
|
||||||
upminutes = (int) info.uptime / 60;
|
if (uphours) {
|
||||||
uphours = (upminutes / 60) % 24;
|
snprintf(ubuf,buf_size,"%d hour%s, ", uphours, (uphours != 1) ? "s" : "");
|
||||||
upminutes %= 60;
|
strcat(sbuf, ubuf);
|
||||||
if (uphours)
|
}
|
||||||
snprintf(ubuf,buf_size,"%2d:%02d", uphours, upminutes);
|
snprintf(ubuf,buf_size,"%d minute%s", upminutes, (upminutes != 1) ? "s" : "");
|
||||||
else
|
|
||||||
snprintf(ubuf,buf_size,"%d min", upminutes);
|
|
||||||
strcat(sbuf, ubuf);
|
strcat(sbuf, ubuf);
|
||||||
|
|
||||||
//paint uptime
|
//paint uptime
|
||||||
|
Reference in New Issue
Block a user