pr_time.c (8109e672e42d323d032c8063822997acdc159a24) pr_time.c (69b41093b5e335a9d938be3ea703f53887ab1201)
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)pr_time.c 8.2 (Berkeley) 4/4/94";
37#endif
38static const char rcsid[] =
1/*-
2 * Copyright (c) 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
36static char sccsid[] = "@(#)pr_time.c 8.2 (Berkeley) 4/4/94";
37#endif
38static const char rcsid[] =
39 "$Id: pr_time.c,v 1.10 1997/08/26 06:59:34 charnier Exp $";
39 "$Id: pr_time.c,v 1.11 1997/12/28 17:50:10 alex Exp $";
40#endif /* not lint */
41
42#include <sys/types.h>
43#include <sys/time.h>
44
45#include <stdio.h>
46#include <string.h>
47

--- 35 unchanged lines hidden (view full) ---

83 (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
84 buf[sizeof(buf) - 1] = '\0';
85 (void)printf("%s", buf);
86}
87
88/*
89 * pr_idle --
90 * Display the idle time.
40#endif /* not lint */
41
42#include <sys/types.h>
43#include <sys/time.h>
44
45#include <stdio.h>
46#include <string.h>
47

--- 35 unchanged lines hidden (view full) ---

83 (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
84 buf[sizeof(buf) - 1] = '\0';
85 (void)printf("%s", buf);
86}
87
88/*
89 * pr_idle --
90 * Display the idle time.
91 * Returns number of excess characters that were used for long idle time.
91 */
92int
93pr_idle(idle)
94 time_t idle;
95{
96 /* If idle more than 36 hours, print as a number of days. */
97 if (idle >= 36 * 3600) {
98 int days = idle / 86400;
99 (void)printf(" %dday%s ", days, days > 1 ? "s" : " " );
92 */
93int
94pr_idle(idle)
95 time_t idle;
96{
97 /* If idle more than 36 hours, print as a number of days. */
98 if (idle >= 36 * 3600) {
99 int days = idle / 86400;
100 (void)printf(" %dday%s ", days, days > 1 ? "s" : " " );
101 if (days >= 100)
102 return (2);
100 if (days >= 10)
103 if (days >= 10)
101 return(1);
104 return (1);
102 }
103
104 /* If idle more than an hour, print as HH:MM. */
105 else if (idle >= 3600)
106 (void)printf(" %2d:%02d ",
107 (int)(idle / 3600), (int)((idle % 3600) / 60));
108
109 else if (idle / 60 == 0)
110 (void)printf(" - ");
111
112 /* Else print the minutes idle. */
113 else
114 (void)printf(" %2d ", (int)(idle / 60));
115
105 }
106
107 /* If idle more than an hour, print as HH:MM. */
108 else if (idle >= 3600)
109 (void)printf(" %2d:%02d ",
110 (int)(idle / 3600), (int)((idle % 3600) / 60));
111
112 else if (idle / 60 == 0)
113 (void)printf(" - ");
114
115 /* Else print the minutes idle. */
116 else
117 (void)printf(" %2d ", (int)(idle / 60));
118
116 return(0); /* not idle longer than 9 days */
119 return (0); /* not idle longer than 9 days */
117}
120}