void
report_billing() {

  const float seconds_per_day = (float)(86400.0);

  int hours;   /* 0..23 */
  int minutes; /* 0..59 */
  int seconds; /* 0..59 */
  float elapsed_time;
  float billing_seconds;
  float billing_days;

  billing_seconds = timer_seconds(&end_time)
    - timer_seconds(&start_time);

  billing_days = timer_days(&end_date)
    - timer_days(&start_date);

  if (billing_seconds >= 0.0) {
    billing_time = (seconds_per_day * billing_days)
      + billing_seconds;
  }
  else {
    billing_time = (seconds_per_day * (billing_days - (float)(1.0)))
      + billing_seconds;
  }

  elapsed_time = billing_time;
  hours = (int)(elapsed_time / (float)(3600.0));
  elapsed_time = elapsed_time - (((float)(hours)) * (float)(3600.0));
  minutes = (int)(elapsed_time / 60.0);
  elapsed_time = elapsed_time - (((float)(minutes)) * (float)(60.0));
  seconds = (int)(elapsed_time);
  printf("Elapsed Time = %2.2d:%2.2d:%2.2d\n",
	 hours, minutes, seconds);
} /* report_billing */
示例#2
0
文件: shell.cpp 项目: imzacm/thor-os
void uptime_command(const std::vector<std::string>&){
    k_printf("Uptime: %us\n", timer_seconds());
}