25 #include "../common.hpp" 26 #include <boost/chrono.hpp> 27 #include <boost/asio/time_traits.hpp> 28 #include <boost/date_time/posix_time/posix_time_types.hpp> 33 using boost::chrono::duration;
35 typedef duration<boost::int_least32_t, boost::ratio<86400> >
days;
36 using boost::chrono::hours;
37 using boost::chrono::minutes;
38 using boost::chrono::seconds;
40 using boost::chrono::milliseconds;
41 using boost::chrono::microseconds;
42 using boost::chrono::nanoseconds;
44 using boost::chrono::duration_cast;
50 template<
typename Rep,
typename Period,
51 typename =
typename std::enable_if<std::numeric_limits<Rep>::is_signed>::type>
52 constexpr duration<Rep, Period>
53 abs(duration<Rep, Period> d)
55 return d >= d.zero() ? d : -d;
85 typedef duration::rep
rep;
87 typedef boost::chrono::time_point<system_clock>
time_point;
115 typedef duration::rep
rep;
118 static constexpr
bool is_steady =
true;
135 static
boost::posix_time::time_duration
136 to_posix_duration(const duration& duration);
138 friend struct
boost::asio::time_traits<steady_clock>;
206 const
std::
string& format = "%Y-%m-%d %H:%M:%S",
207 const
std::locale& locale =
std::locale("C"));
224 const
std::
string& format = "%Y-%m-%d %H:%M:%S",
225 const
std::locale& locale =
std::locale("C"));
236 template<
class CharT>
237 struct clock_string<
ndn::time::system_clock, CharT>
239 static std::basic_string<CharT>
243 template<
class CharT>
244 struct clock_string<
ndn::time::steady_clock, CharT>
246 static std::basic_string<CharT>
253 #endif // NDN_TIME_HPP boost::chrono::time_point< system_clock > time_point
boost::chrono::time_point< steady_clock > time_point
Copyright (c) 2013-2017 Regents of the University of California.
system_clock::TimePoint fromIsoString(const std::string &isoString)
Convert from the ISO string (YYYYMMDDTHHMMSS,fffffffff) representation to the internal time format...
Copyright (c) 2013-2017 Regents of the University of California.
BOOST_SYSTEM_CLOCK_DURATION duration
static std::time_t to_time_t(const time_point &t) noexcept
static constexpr bool is_steady
static time_point now() noexcept
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
std::string toString(const system_clock::TimePoint &timePoint, const std::string &format, const std::locale &locale)
Convert time point to string with specified format.
system_clock::TimePoint fromString(const std::string &formattedTimePoint, const std::string &format, const std::locale &locale)
Convert from string of specified format into time point.
std::string toIsoString(const system_clock::TimePoint &timePoint)
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
system_clock::TimePoint fromUnixTimestamp(const milliseconds &duration)
Convert UNIX timestamp to system_clock::TimePoint.
milliseconds toUnixTimestamp(const system_clock::TimePoint &point)
Convert system_clock::TimePoint to UNIX timestamp.
static time_point from_time_t(std::time_t t) noexcept
const system_clock::TimePoint & getUnixEpoch()
Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970) ...
duration< boost::int_least32_t, boost::ratio< 86400 > > days