Classes | |
class | CustomClock |
Class implementing custom system or steady clock behavior. More... | |
class | steady_clock |
Steady clock. More... | |
class | system_clock |
System clock. More... | |
class | UnitTestClock |
Clock that can be used in unit tests for time-dependent tests independent of wall clock. More... | |
class | UnitTestClockTraits |
Traits for UnitTestClock, defining default behavior for different clocks. More... | |
class | UnitTestClockTraits< system_clock > |
Specialization of UnitTestClockTraits for system_clock. More... | |
Typedefs | |
typedef boost::chrono::steady_clock | base_steady_clock |
using | CustomSteadyClock = CustomClock< steady_clock > |
using | CustomSystemClock = CustomClock< system_clock > |
using | days = duration< int_fast32_t, boost::ratio< 86400 > > |
using | UnitTestSteadyClock = UnitTestClock< steady_clock > |
using | UnitTestSystemClock = UnitTestClock< system_clock > |
Functions | |
template<typename Rep , typename Period , typename = std::enable_if_t<std::numeric_limits<Rep>::is_signed>> | |
constexpr duration< Rep, Period > | abs (duration< Rep, Period > d) |
static boost::posix_time::ptime | convertToPosixTime (const system_clock::TimePoint &timePoint) |
static system_clock::TimePoint | convertToTimePoint (const boost::posix_time::ptime &ptime) |
system_clock::TimePoint | fromIsoString (const std::string &isoString) |
Convert from the ISO string (YYYYMMDDTHHMMSS,fffffffff) representation to the internal time format. More... | |
system_clock::TimePoint | fromString (const std::string &timePointStr, const std::string &format="%Y-%m-%d %H:%M:%S", const std::locale &locale=std::locale("C")) |
Convert from string of specified format into time point. More... | |
system_clock::TimePoint | fromUnixTimestamp (milliseconds duration) |
Convert UNIX timestamp to system_clock::TimePoint. More... | |
const system_clock::TimePoint & | getUnixEpoch () |
Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970) More... | |
void | setCustomClocks (shared_ptr< CustomSteadyClock > steadyClock=nullptr, shared_ptr< CustomSystemClock > systemClock=nullptr) |
Set custom system and steady clocks. More... | |
std::string | toIsoString (const system_clock::TimePoint &timePoint) |
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff) More... | |
std::string | toString (const system_clock::TimePoint &timePoint, const std::string &format="%Y-%m-%d %H:%M:%S", const std::locale &locale=std::locale("C")) |
Convert time point to string with specified format. More... | |
milliseconds | toUnixTimestamp (const system_clock::TimePoint &point) |
Convert system_clock::TimePoint to UNIX timestamp. More... | |
Variables | |
static shared_ptr< CustomSteadyClock > | g_steadyClock |
static shared_ptr< CustomSystemClock > | g_systemClock |
typedef boost::chrono::steady_clock ndn::time::base_steady_clock |
using ndn::time::CustomSteadyClock = typedef CustomClock<steady_clock> |
Definition at line 54 of file time-custom-clock.hpp.
using ndn::time::CustomSystemClock = typedef CustomClock<system_clock> |
Definition at line 53 of file time-custom-clock.hpp.
using ndn::time::days = typedef duration<int_fast32_t, boost::ratio<86400> > |
using ndn::time::UnitTestSteadyClock = typedef UnitTestClock<steady_clock> |
Definition at line 109 of file time-unit-test-clock.hpp.
using ndn::time::UnitTestSystemClock = typedef UnitTestClock<system_clock> |
Definition at line 108 of file time-unit-test-clock.hpp.
constexpr duration<Rep, Period> ndn::time::abs | ( | duration< Rep, Period > | d | ) |
|
static |
|
static |
system_clock::TimePoint ndn::time::fromIsoString | ( | const std::string & | isoString | ) |
Convert from the ISO string (YYYYMMDDTHHMMSS,fffffffff) representation to the internal time format.
Examples of accepted ISO strings:
system_clock::TimePoint ndn::time::fromString | ( | const std::string & | timePointStr, |
const std::string & | format = "%Y-%m-%d %H:%M:%S" , |
||
const std::locale & | locale = std::locale("C") |
||
) |
Convert from string of specified format into time point.
By default, Y-m-d H:M:S
is used, accepting dates like 2014-04-10 22:51:00
timePointStr | string representing time point |
format | input output format (default: Y-m-d H:M:S ) |
locale | input locale (default: "C" locale) |
system_clock::TimePoint ndn::time::fromUnixTimestamp | ( | milliseconds | duration | ) |
Convert UNIX timestamp to system_clock::TimePoint.
const system_clock::TimePoint & ndn::time::getUnixEpoch | ( | ) |
Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970)
void ndn::time::setCustomClocks | ( | shared_ptr< CustomSteadyClock > | steadyClock = nullptr , |
shared_ptr< CustomSystemClock > | systemClock = nullptr |
||
) |
std::string ndn::time::toIsoString | ( | const system_clock::TimePoint & | timePoint | ) |
Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff)
If timePoint
contains doesn't contain fractional seconds, the output format is YYYYMMDDTHHMMSS
Examples:
std::string ndn::time::toString | ( | const system_clock::TimePoint & | timePoint, |
const std::string & | format = "%Y-%m-%d %H:%M:%S" , |
||
const std::locale & | locale = std::locale("C") |
||
) |
Convert time point to string with specified format.
By default, Y-m-d H:M:S
is used, producing dates like 2014-04-10 22:51:00
timePoint | time point of system_clock |
format | desired output format (default: Y-m-d H:M:S ) |
locale | desired locale (default: "C" locale) |
milliseconds ndn::time::toUnixTimestamp | ( | const system_clock::TimePoint & | point | ) |
Convert system_clock::TimePoint to UNIX timestamp.
|
static |
|
static |