Changeset View
Changeset View
Standalone View
Standalone View
src/utiltime.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime) { | ||||
static std::locale classic(std::locale::classic()); | static std::locale classic(std::locale::classic()); | ||||
// std::locale takes ownership of the pointer | // std::locale takes ownership of the pointer | ||||
std::locale loc(classic, new boost::posix_time::time_facet(pszFormat)); | std::locale loc(classic, new boost::posix_time::time_facet(pszFormat)); | ||||
std::stringstream ss; | std::stringstream ss; | ||||
ss.imbue(loc); | ss.imbue(loc); | ||||
ss << boost::posix_time::from_time_t(nTime); | ss << boost::posix_time::from_time_t(nTime); | ||||
return ss.str(); | return ss.str(); | ||||
} | } | ||||
std::string FormatISO8601DateTime(int64_t nTime) { | |||||
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); | |||||
} | |||||
std::string FormatISO8601Date(int64_t nTime) { | |||||
return DateTimeStrFormat("%Y-%m-%d", nTime); | |||||
} | |||||
std::string FormatISO8601Time(int64_t nTime) { | |||||
return DateTimeStrFormat("%H:%M:%SZ", nTime); | |||||
} |