Document chrono

This commit is contained in:
Victor Zverovich
2020-11-07 10:19:40 -08:00
parent 0506b328b5
commit 263bb0e68d
2 changed files with 13 additions and 14 deletions
+8 -11
View File
@@ -415,18 +415,15 @@ For example::
#include <fmt/chrono.h>
int main() {
using namespace std::literals::chrono_literals;
fmt::print("Default format: {} {}\n", 42s, 100ms);
fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
}
std::time_t t = std::time(nullptr);
// Prints "The date is 2020-11-07." (with the current date):
fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t));
prints:
.. code:: none
Default format: 42s 100ms
strftime-like format: 03:15:30
using namespace std::literals::chrono_literals;
// Prints "Default format: 42s 100ms":
fmt::print("Default format: {} {}\n", 42s, 100ms);
// Prints "strftime-like format: 03:15:30":
fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
Chrono format specifications are described in :ref:`chrono-specs`.