22 #ifndef NDN_CXX_UTIL_TIME_HPP 23 #define NDN_CXX_UTIL_TIME_HPP 27 #include <boost/asio/wait_traits.hpp> 28 #include <boost/chrono.hpp> 33 template<
typename Rep,
typename Period>
34 using duration = boost::chrono::duration<Rep, Period>;
36 using boost::chrono::duration_cast;
56 template<typename Rep, typename Period, typename = std::enable_if_t<std::numeric_limits<Rep>::is_signed>>
60 return d >= d.zero() ? d : -d;
65 inline namespace literals {
66 inline namespace time_literals {
69 operator "" _day(
unsigned long long days)
75 operator "" _day(
long double days)
81 operator "" _days(
unsigned long long days)
87 operator "" _days(
long double days)
93 operator "" _h(
unsigned long long hrs)
99 operator "" _h(
long double hrs)
105 operator "" _min(
unsigned long long mins)
111 operator "" _min(
long double mins)
117 operator "" _s(
unsigned long long secs)
123 operator "" _s(
long double secs)
129 operator "" _ms(
unsigned long long msecs)
135 operator "" _ms(
long double msecs)
141 operator "" _us(
unsigned long long usecs)
147 operator "" _us(
long double usecs)
153 operator "" _ns(
unsigned long long nsecs)
159 operator "" _ns(
long double nsecs)
169 using namespace literals::time_literals;
198 using rep = duration::rep;
201 static constexpr
bool is_steady = boost::chrono::system_clock::is_steady;
213 from_time_t(
std::time_t t) noexcept;
228 using rep = duration::rep;
231 static constexpr
bool is_steady =
true;
330 const
std::
string& format = "%Y-%m-%d %H:%M:%S",
331 const
std::locale& locale =
std::locale("C"));
348 const
std::
string& format = "%Y-%m-%d %H:%M:%S",
349 const
std::locale& locale =
std::locale("C"));
357 template<
typename CharT>
360 static std::basic_string<CharT>
364 template<
typename CharT>
367 static std::basic_string<CharT>
371 extern template struct clock_string<ndn::time::system_clock, char>;
372 extern template struct clock_string<ndn::time::steady_clock, char>;
377 #endif // NDN_CXX_UTIL_TIME_HPP boost::chrono::seconds seconds
boost::chrono::minutes minutes
boost::chrono::system_clock::duration duration
Copyright (c) 2011-2015 Regents of the University of California.
boost::chrono::time_point< system_clock > time_point
duration< int_fast32_t, boost::ratio< 2629746 > > months
boost::chrono::steady_clock::duration duration
boost::chrono::time_point< steady_clock > time_point
boost::chrono::microseconds microseconds
boost::chrono::duration< Rep, Period > duration
duration< int_fast32_t, boost::ratio< 604800 > > weeks
duration< int_fast32_t, boost::ratio< 31556952 > > years
milliseconds toUnixTimestamp(const system_clock::time_point &point)
Convert system_clock::time_point to UNIX timestamp.
constexpr duration< Rep, Period > abs(duration< Rep, Period > d)
Common includes and macros used throughout the library.
system_clock::time_point fromUnixTimestamp(milliseconds duration)
Convert UNIX timestamp to system_clock::time_point.
std::string toIsoExtendedString(const system_clock::time_point &timePoint)
Convert to the ISO 8601 string representation, extended format (YYYY-MM-DDTHH:MM:SS,fffffffff).
const system_clock::time_point & getUnixEpoch()
Return a system_clock::time_point representing the UNIX time epoch, i.e., 00:00:00 UTC on 1 January 1...
system_clock::time_point fromString(const std::string &timePointStr, const std::string &format, const std::locale &locale)
Convert from string of specified format into time point.
std::string toString(const system_clock::time_point &timePoint, const std::string &format, const std::locale &locale)
Convert time point to string with specified format.
system_clock::time_point fromIsoString(const std::string &isoString)
Convert from the ISO 8601 basic string format (YYYYMMDDTHHMMSS,fffffffff) to the internal time format...
duration< int_fast32_t, boost::ratio< 86400 > > days
std::string toIsoString(const system_clock::time_point &timePoint)
Convert to the ISO 8601 string representation, basic format (YYYYMMDDTHHMMSS,fffffffff).
boost::chrono::hours hours
system_clock::time_point fromIsoExtendedString(const std::string &isoString)
Convert from the ISO 8601 extended string format (YYYY-MM-DDTHH:MM:SS,fffffffff) to the internal time...
boost::chrono::nanoseconds nanoseconds
boost::chrono::milliseconds milliseconds