#include "real_time.hpp"

namespace hr
{
  real_time::real_time(int s, int n) : m_sec{ s }, m_nsec{ n }
  {
    normalize();
  }

  real_time real_time::frame2rt(long frame, unsigned int sample_rate)
  {
    if (frame < 0) return -frame2rt(-frame, sample_rate);
    int sec = int(frame / long(sample_rate));
    frame -= sec * long(sample_rate);
    int nsec = (int)((double(frame) / double(sample_rate)) * ONE_BILLION + 0.5);
    return real_time(sec, nsec);
  }
}
