From 57f65ec30c045a73270733294080258925ca9a69 Mon Sep 17 00:00:00 2001 From: Cesare Tirabassi Date: Mon, 27 Jul 2009 15:09:18 -0600 Subject: [PATCH] Fix user_times bug (launchpad #405188). --- src/conky.c | 1 - src/users.c | 19 ++----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/conky.c b/src/conky.c index e59ff9fb..f7f748f6 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1,5 +1,4 @@ /* Conky, a system monitor, based on torsmo - * * * Any original torsmo code is licensed under the BSD license * diff --git a/src/users.c b/src/users.c index 61b9200e..0f2ffcde 100644 --- a/src/users.c +++ b/src/users.c @@ -24,7 +24,7 @@ * along with this program. If not, see . * * vim: ts=4 sw=4 noet ai cindent syntax=c - * + * -*- c-basic-offset: 4; tab-width: 4 -*- */ #include "conky.h" @@ -76,7 +76,6 @@ static void user_time(char *ptr) { const struct utmp *usr; time_t log_in, real, diff; - struct tm *dtime; char buf[BUFLEN] = ""; setutent(); @@ -85,21 +84,7 @@ static void user_time(char *ptr) log_in = usr->ut_time; time(&real); diff = difftime(real, log_in); - dtime = localtime(&diff); - dtime->tm_year = dtime->tm_year - 70; - dtime->tm_mon = dtime->tm_mon - 1; - dtime->tm_mday = dtime->tm_mday - 1; - if (dtime->tm_year > 0) { - strftime(buf, BUFLEN, "%yy %mm %dd %Hh %Mm", dtime); - } else if (dtime->tm_mon > 0) { - strftime(buf, BUFLEN, "%mm %dd %Hh %Mm", dtime); - } else if (dtime->tm_mday > 0) { - strftime(buf, BUFLEN, "%dd %Hh %Mm", dtime); - } else if (dtime->tm_hour > 0) { - strftime(buf, BUFLEN, "%Hh %Mm", dtime); - } else if (dtime->tm_min > 0) { - strftime(buf, BUFLEN, "%Mm", dtime); - } + format_seconds(buf, BUFLEN, diff); if (strlen(ptr) + strlen(buf) + 1 <= BUFLEN) { strncat(ptr, buf, BUFLEN-strlen(ptr)-1); }