Vanetza
 
Loading...
Searching...
No Matches
clock.hpp
1#ifndef CLOCK_HPP_2FCBLXSJ
2#define CLOCK_HPP_2FCBLXSJ
3
4#include <boost/date_time/posix_time/posix_time_types.hpp>
5#include <chrono>
6#include <cstdint>
7#include <ratio>
8
9namespace vanetza
10{
11
12/**
13 * A Clock similar to std::chrono with epoch at 2004-01-01 at midnight
14 */
15class Clock
16{
17public:
18 typedef int64_t rep;
19 typedef std::ratio<1, 1000 * 1000> period;
20 typedef std::chrono::duration<rep, period> duration;
21 typedef std::chrono::time_point<Clock> time_point;
22 typedef boost::posix_time::ptime date_time;
23
24 static constexpr bool is_steady() { return true; }
25 static time_point at(const date_time&);
26 static date_time at(const time_point&);
27 static const date_time& epoch();
28
29 /**
30 * \brief create time point
31 * \param at time string formatted like 2016-07-15 09:48:32
32 * \return time point
33 */
34 static time_point at(const std::string& at);
35};
36
37} // namespace vanetza
38
39#endif /* CLOCK_HPP_2FCBLXSJ */
40