MCPcopy Create free account
hub / github.com/coreutils/coreutils / idle_string

Function idle_string

src/who.c:179–205  ·  view source on GitHub ↗

Return a string representing the time between WHEN and now. BOOTTIME is the time of last reboot. FIXME: locale? */

Source from the content-addressed store, hash-verified

177 BOOTTIME is the time of last reboot.
178 FIXME: locale? */
179static char const *
180idle_string (time_t when, time_t boottime)
181{
182 static time_t now = TYPE_MINIMUM (time_t);
183
184 if (now == TYPE_MINIMUM (time_t))
185 time (&now);
186
187 int seconds_idle;
188 if (boottime < when && when <= now
189 && ! ckd_sub (&seconds_idle, now, when)
190 && seconds_idle < 24 * 60 * 60)
191 {
192 if (seconds_idle < 60)
193 return " . ";
194 else
195 {
196 static char idle_hhmm[IDLESTR_LEN];
197 sprintf (idle_hhmm, "%02d:%02d",
198 seconds_idle / (60 * 60),
199 (seconds_idle % (60 * 60)) / 60);
200 return idle_hhmm;
201 }
202 }
203
204 return _(" old ");
205}
206
207/* Return a time string. */
208static char const *

Callers 1

print_userFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected