/* Blinker
Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
a blinkenarea.org project */
#include <errno.h>
#include <iomanip>
#include <math.h>
#include <sstream>
#include <stdint.h>
#include <string>
#include <sys/time.h>
#include <time.h>
#include "Time.h"
namespace Blinker {
const Time Time::zero(0); ///< zero time
/**
* @brief get current time
* @return current time
*/
Time Time::now()
{
Time now;
struct timeval tv;
gettimeofday(&tv, NULL);
now.m_sec = tv.tv_sec;
now.m_ns = tv.tv_usec * 1000;
return now;
}
/// constructor
Time::Time():
m_sec(0),
m_ns(0)
{
}
/**
* @brief constructor from seconds
* @param[in] t time in seconds
*/
Time::Time(time_t t):
m_sec(t),
m_ns(0)
{