Use std::localtime() instead of plain C localtime()

This commit is contained in:
Charles Dang 2018-05-13 22:26:10 +11:00
parent d26824901d
commit 00bea6494f
4 changed files with 5 additions and 5 deletions

View file

@ -22,14 +22,14 @@ namespace utils {
std::string format_time_summary(std::time_t t) {
std::time_t curtime = std::time(nullptr);
const struct tm* timeptr = localtime(&curtime);
const struct tm* timeptr = std::localtime(&curtime);
if(timeptr == nullptr) {
return "";
}
const struct tm current_time = *timeptr;
timeptr = localtime(&t);
timeptr = std::localtime(&t);
if(timeptr == nullptr) {
return "";
}

View file

@ -174,7 +174,7 @@ debug_clock::time::time() : hour(0), minute(0), second(0), millisecond(0)
void debug_clock::time::set_current_time()
{
std::time_t now = ::std::time(nullptr);
tm* stamp = localtime(&now);
tm* stamp = std::localtime(&now);
hour = stamp->tm_hour;
minute = stamp->tm_min;

View file

@ -213,7 +213,7 @@ const config& save_info::summary() const
std::string save_info::format_time_local() const
{
if(tm* tm_l = localtime(&modified())) {
if(tm* tm_l = std::localtime(&modified())) {
const std::string format = preferences::use_twelve_hour_clock_format()
? _("%a %b %d %I:%M %p %Y")
: _("%a %b %d %H:%M %Y");

View file

@ -330,7 +330,7 @@ static lg::log_domain log_server("server");
if (duration.substr(0,4) == "TIME") {
struct tm* loc;
loc = localtime(time);
loc = std::localtime(time);
std::size_t number = 0;
for (std::string::const_iterator i = duration.begin() + 4;