version 1.11, 2003/06/03 02:56:22 |
version 1.12, 2003/11/26 00:31:27 |
|
|
/* |
/* |
* pr_attime -- |
* pr_attime -- |
* Print the time since the user logged in. |
* Print the time since the user logged in. |
* |
|
* Note: SCCS forces the bizarre string manipulation, things like |
|
* 8.2 get replaced in the source code. |
|
*/ |
*/ |
void |
void |
pr_attime(started, now) |
pr_attime(time_t *started, time_t *now) |
time_t *started, *now; |
|
{ |
{ |
static char buf[256]; |
static char buf[256]; |
struct tm *tp; |
struct tm *tp; |
time_t diff; |
time_t diff; |
char fmt[20]; |
const char *fmt; |
int today; |
int today; |
|
|
today = localtime(now)->tm_yday; |
today = localtime(now)->tm_yday; |
|
|
|
|
/* If more than a week, use day-month-year. */ |
/* If more than a week, use day-month-year. */ |
if (diff > SECSPERDAY * DAYSPERWEEK) |
if (diff > SECSPERDAY * DAYSPERWEEK) |
(void)strlcpy(fmt, "%d%b%y", sizeof fmt); |
fmt = "%d%b%y"; |
|
|
/* If not today, use day-hour-am/pm. */ |
/* If not today, use day-hour-am/pm. */ |
else if (tp->tm_yday != today ) { |
else if (tp->tm_yday != today ) { |
(void)strlcpy(fmt, __CONCAT("%a%", "I%p"), sizeof fmt); |
fmt = "%a%I%p"; |
} |
} |
|
|
/* Default is hh:mm{am,pm}. */ |
/* Default is hh:mm{am,pm}. */ |
else { |
else { |
(void)strlcpy(fmt, __CONCAT("%l:%", "M%p"), sizeof fmt); |
fmt = "%l:%M%p"; |
} |
} |
|
|
(void)strftime(buf, sizeof(buf) -1, fmt, tp); |
(void)strftime(buf, sizeof buf -1, fmt, tp); |
buf[sizeof buf - 1] = '\0'; |
buf[sizeof buf - 1] = '\0'; |
(void)printf("%s", buf); |
(void)printf("%s", buf); |
} |
} |
|
|
* Display the idle time. |
* Display the idle time. |
*/ |
*/ |
void |
void |
pr_idle(idle) |
pr_idle(time_t idle) |
time_t idle; |
|
{ |
{ |
int days = idle / SECSPERDAY; |
int days = idle / SECSPERDAY; |
|
|