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

Function idle_string

src/pinky.c:155–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153 that this function is first run. */
154
155static char const *
156idle_string (time_t when)
157{
158 static time_t now = 0;
159 static char buf[INT_STRLEN_BOUND (intmax_t) + sizeof "d"];
160
161 if (now == 0)
162 time (&now);
163
164 time_t seconds_idle = now - when;
165 if (seconds_idle < 60) /* One minute. */
166 return " ";
167 if (seconds_idle < (24 * 60 * 60)) /* One day. */
168 {
169 int hours = seconds_idle / (60 * 60);
170 int minutes = (seconds_idle % (60 * 60)) / 60;
171 sprintf (buf, "%02d:%02d", hours, minutes);
172 }
173 else
174 {
175 intmax_t days = seconds_idle / (24 * 60 * 60);
176 sprintf (buf, "%jdd", days);
177 }
178 return buf;
179}
180
181/* Return a time string. */
182static char const *

Callers 1

print_entryFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected