All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ndn::time Namespace Reference

Data Structures

class  system_clock
 System clock. More...
 
class  steady_clock
 Steady clock. More...
 

Typedefs

typedef duration
< boost::int_least32_t,
boost::ratio< 86400 > > 
days
 

Functions

const system_clock::TimePointgetUnixEpoch ()
 Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970) More...
 
milliseconds toUnixTimestamp (const system_clock::TimePoint &point)
 Convert system_clock::TimePoint to UNIX timestamp. More...
 
system_clock::TimePoint fromUnixTimestamp (const milliseconds &duration)
 Convert UNIX timestamp to system_clock::TimePoint. More...
 
std::string toIsoString (const system_clock::TimePoint &timePoint)
 Convert to the ISO string representation of the time (YYYYMMDDTHHMMSS,fffffffff) More...
 
system_clock::TimePoint fromIsoString (const std::string &isoString)
 Convert from the ISO string (YYYYMMDDTHHMMSS,fffffffff) representation to the internal time format. 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...
 
system_clock::TimePoint fromString (const std::string &formattedTimePoint, 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...
 

Typedef Documentation

typedef duration<boost::int_least32_t, boost::ratio<86400> > ndn::time::days

Definition at line 18 of file time.hpp.

Function Documentation

system_clock::TimePoint ndn::time::fromIsoString ( const std::string &  isoString)
inline

Convert from the ISO string (YYYYMMDDTHHMMSS,fffffffff) representation to the internal time format.

Examples of accepted ISO strings:

  • with fractional nanoseconds: 20020131T100001,123456789
  • with fractional microseconds: 20020131T100001,123456
  • with fractional milliseconds: 20020131T100001,123
  • without fractional seconds: 20020131T100001

Definition at line 163 of file time.hpp.

system_clock::TimePoint ndn::time::fromString ( const std::string &  formattedTimePoint,
const std::string &  format = "%Y-%m-%d %H:%M:%S",
const std::locale &  locale = std::locale("C") 
)
inline

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

Parameters
formattedTimePointstring representing time point
formatinput output format (default: Y-m-d H:M:S)
localeinput locale (default: "C" locale)
See Also
http://www.boost.org/doc/libs/1_48_0/doc/html/date_time/date_time_io.html#date_time.format_flags described possible formatting flags

Definition at line 222 of file time.hpp.

system_clock::TimePoint ndn::time::fromUnixTimestamp ( const milliseconds &  duration)
inline

Convert UNIX timestamp to system_clock::TimePoint.

Definition at line 116 of file time.hpp.

const system_clock::TimePoint& ndn::time::getUnixEpoch ( )
inline

Get system_clock::TimePoint representing UNIX time epoch (00:00:00 on Jan 1, 1970)

Definition at line 97 of file time.hpp.

std::string ndn::time::toIsoString ( const system_clock::TimePoint &  timePoint)
inline

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:

  • with fractional nanoseconds: 20020131T100001,123456789
  • with fractional microseconds: 20020131T100001,123456
  • with fractional milliseconds: 20020131T100001,123
  • without fractional seconds: 20020131T100001

Definition at line 135 of file time.hpp.

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") 
)
inline

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

Parameters
timePointtime point of system_clock
formatdesired output format (default: Y-m-d H:M:S)
localedesired locale (default: "C" locale)
See Also
http://www.boost.org/doc/libs/1_48_0/doc/html/date_time/date_time_io.html#date_time.format_flags described possible formatting flags

Definition at line 190 of file time.hpp.

milliseconds ndn::time::toUnixTimestamp ( const system_clock::TimePoint &  point)
inline

Convert system_clock::TimePoint to UNIX timestamp.

Definition at line 107 of file time.hpp.