/*------------------------------------------------------------------------------
 src/lib/dj/time.cxx
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#include "djTime.h"
#include <time.h>

namespace dj {

void Timer::start()
{
  timeval t;
  ::gettimeofday(&t, 0);
  _t0.tv_sec = t.tv_sec;
  _t0.tv_usec = t.tv_usec;
}

void Timer::check()
{
  timeval t;
  ::gettimeofday(&t, 0);
  _t1.tv_sec = t.tv_sec;
  _t1.tv_usec = t.tv_usec;
}

time_t timeCurrent() { return ::time(0); }

const Str timeToStr(time_t in)
{
  Str out(::ctime(&in));

  // Remove new-line.
  //
  out.shift();

  return out;
}

}
