...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::date_time::c_time — Provides a uniform interface to some 'ctime' functions.
// In header: <boost/date_time/c_time.hpp> struct c_time { // public static functions static std::tm * localtime(const std::time_t *, std::tm *); static std::tm * gmtime(const std::time_t *, std::tm *); static std::tm * localtime(const std::time_t *, std::tm *); static std::tm * gmtime(const std::time_t *, std::tm *); };
Provides a uniform interface to some ctime functions and their '_r' counterparts. The '_r' functions require a pointer to a user created std::tm struct whereas the regular functions use a staticly created struct and return a pointer to that. These wrapper functions require the user to create a std::tm struct and send in a pointer to it. This struct may be used to store the resulting time. The returned pointer may or may not point to this struct, however, it will point to the result of the corresponding function. All functions do proper checking of the C function results and throw exceptions on error. Therefore the functions will never return NULL.
c_time
public static functionsstatic std::tm * localtime(const std::time_t * t, std::tm * result);requires a pointer to a user created std::tm struct
static std::tm * gmtime(const std::time_t * t, std::tm * result);requires a pointer to a user created std::tm struct
static std::tm * localtime(const std::time_t * t, std::tm * result);requires a pointer to a user created std::tm struct
static std::tm * gmtime(const std::time_t * t, std::tm * result);requires a pointer to a user created std::tm struct