Update date formatting example to use threadsafe localtime

This commit is contained in:
Lindsay Roberts 2020-05-02 16:58:23 +03:00 committed by Victor Zverovich
parent d6abb2fa03
commit d59751f0f0

View File

@ -408,7 +408,7 @@ formatting::
std::time_t t = std::time(nullptr); std::time_t t = std::time(nullptr);
// Prints "The date is 2016-04-29." (with the current date) // Prints "The date is 2016-04-29." (with the current date)
fmt::print("The date is {:%Y-%m-%d}.", *std::localtime(&t)); fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t));
The format string syntax is described in the documentation of The format string syntax is described in the documentation of
`strftime <http://en.cppreference.com/w/cpp/chrono/c/strftime>`_. `strftime <http://en.cppreference.com/w/cpp/chrono/c/strftime>`_.