Code cleanup

This commit is contained in:
Pierre Pronchery 2006-11-26 14:02:17 +00:00
parent dae17c6dad
commit b5186ccbd7
2 changed files with 7 additions and 4 deletions

View File

@ -582,14 +582,17 @@ static void _long_date(time_t date, char buf[15])
{
struct tm tm;
static time_t sixmonths = -1;
size_t len;
if(sixmonths == -1)
sixmonths = time(NULL) - 15552000;
localtime_r(&date, &tm);
if(date < sixmonths)
strftime(buf, 14, "%b %e %Y", &tm);
len = strftime(buf, 14, "%b %e %Y", &tm);
else
strftime(buf, 14, "%b %e %H:%M", &tm);
len = strftime(buf, 14, "%b %e %H:%M", &tm);
if(len == 0)
buf[0] = '\0';
}
static char _file_mode_letter(mode_t mode)

View File

@ -41,8 +41,8 @@ static int _who(Prefs * prefs)
printf(" %c", '?');
printf(" %-8s", u->ut_line);
t = u->ut_tv.tv_sec;
if((tm = localtime(&t)) == NULL || strftime(buf,
sizeof(buf), "%b %e %H:%M", tm) == 0)
if((tm = localtime(&t)) == NULL || strftime(buf, sizeof(buf),
"%b %e %H:%M", tm) == 0)
strcpy(buf, "n/a");
printf(" %s\n", buf);
}