/* * call-seq: * Uptime.uptime * * Calculates and returns the number of days, hours, minutes and * seconds the system has been running as a colon-separated string. */ static VALUE uptime_uptime() { char c_string[MAXSTRINGSIZE]; long seconds, days, hours, minutes; seconds = get_uptime_secs(); days = seconds/86400; seconds -= days*86400; hours = seconds/3600; seconds -= hours*3600; minutes = seconds/60; seconds -= minutes*60; sprintf(c_string, "%ld:%ld:%ld:%ld", days, hours, minutes, seconds); return rb_str_new2(c_string); }