<reponame>thatguystone/paratec<filename>src/time.cpp
/**
 * @file
 * @author <NAME> <<EMAIL>>
 * @copyright 2015 <NAME>
 *
 * This file is part of paratec and is released under the MIT License:
 * http://opensource.org/licenses/MIT
 */

#include "time.hpp"

namespace pt
{
namespace time
{

point now()
{
	return std::chrono::steady_clock::now();
}

double toSeconds(duration d)
{
	return std::chrono::duration_cast<std::chrono::duration<double>>(d).count();
}

uint64_t toNanoSeconds(duration d)
{
	return (uint64_t)std::chrono::duration_cast<std::chrono::nanoseconds>(d)
		.count();
}

duration toDuration(double secs)
{
	return std::chrono::duration_cast<duration>(
		std::chrono::duration<double, std::ratio<1, 1>>(secs));
}
}
}
