#ifdef DOC_BUILD_INTERNAL
#endif
#include "clock.h"
  float clock_Akku[clock_TYPESIZE];
  CLOCK_TMS clock_Counters[clock_TYPESIZE];
CLOCK clock_Create(MEMORY Mem)
{
  unsigned i;
  CLOCK clock;
  clock = memory_Malloc(Mem, sizeof(*clock));
  for (i = 0; i < clock_TYPESIZE; i++)
    clock->akku[i] = 0;
  return clock;
}
void clock_Delete(MEMORY Mem, CLOCK Clock)
{
  memory_Free(Mem, Clock, sizeof(*Clock));
}
void clock_Start(CLOCK Clock, CLOCKTYPE Type)
{
  gettimeofday(&(Clock->counters[Type]), NULL);
}
void clock_StopPassedTime(CLOCK Clock, CLOCKTYPE Type)
{
  CLOCK_TMS newtime;
  gettimeofday(&newtime, NULL);
  Clock->akku[Type] = clock_GetSeconds(Clock, Type);
}
void clock_StopAddPassedTime(CLOCK Clock, CLOCKTYPE Type)
{
  CLOCK_TMS newtime;
  gettimeofday(&newtime, NULL);
  Clock->akku[Type] += clock_GetSeconds(Clock, Type);
}
float clock_GetAkku(CLOCK Clock, CLOCKTYPE Type)
{
  return Clock->akku[Type];
}
float clock_GetSeconds(CLOCK Clock, CLOCKTYPE Type)
{
  CLOCK_TMS newtime;
  time_t seconds_passed;
  long microseconds_passed;
  gettimeofday(&newtime, NULL);
  seconds_passed = newtime.tv_sec - Clock->counters[Type].tv_sec;
  microseconds_passed = newtime.tv_usec - Clock->counters[Type].tv_usec;
  return ((float) seconds_passed
   + (microseconds_passed /(float)1000000));
}
void clock_PrintTime(CLOCK Clock, CLOCKTYPE Type)
{
  NAT hours, minutes;
  float seconds;
  seconds = Clock->akku[Type];
  hours = (NAT)seconds/3600;
  seconds -= hours*3600;
  minutes = (NAT)seconds/60;
  seconds -= (minutes*60);
  if (seconds >= 10.0)
    printf("%zu:%0zu:%2.2f",hours,minutes,seconds);
  else
    printf("%zu:%02zu:0%2.2f",hours,minutes,seconds);
}
