mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-05 00:40:12 +00:00
Document chrono
This commit is contained in:
parent
263bb0e68d
commit
a4fae96c96
@ -416,12 +416,15 @@ For example::
|
|||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
|
|
||||||
std::time_t t = std::time(nullptr);
|
std::time_t t = std::time(nullptr);
|
||||||
|
|
||||||
// Prints "The date is 2020-11-07." (with the current date):
|
// Prints "The date is 2020-11-07." (with the current date):
|
||||||
fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t));
|
fmt::print("The date is {:%Y-%m-%d}.", fmt::localtime(t));
|
||||||
|
|
||||||
using namespace std::literals::chrono_literals;
|
using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
// Prints "Default format: 42s 100ms":
|
// Prints "Default format: 42s 100ms":
|
||||||
fmt::print("Default format: {} {}\n", 42s, 100ms);
|
fmt::print("Default format: {} {}\n", 42s, 100ms);
|
||||||
|
|
||||||
// Prints "strftime-like format: 03:15:30":
|
// Prints "strftime-like format: 03:15:30":
|
||||||
fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
|
fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s);
|
||||||
|
|
||||||
|
@ -326,10 +326,10 @@ Literal chars are copied unchanged to the output. Precision is valid only for
|
|||||||
|
|
||||||
*conversion_spec* are conversion specifiers documented in `strftime
|
*conversion_spec* are conversion specifiers documented in `strftime
|
||||||
<http://en.cppreference.com/w/cpp/chrono/c/strftime>`_ for ``std::tm`` and
|
<http://en.cppreference.com/w/cpp/chrono/c/strftime>`_ for ``std::tm`` and
|
||||||
in `Meaning of conversion specifiers <https://eel.is/c++draft/time.format>`
|
in `Meaning of conversion specifiers <https://eel.is/c++draft/time.format>`_
|
||||||
for chrono durations and time points. Specifiers that have a calendaric
|
for chrono durations and time points. Specifiers that have a calendaric
|
||||||
component such as `'d'` are valid only for ``std::tm`` and not durations or time
|
component such as `'d'` (the day of month) are valid only for ``std::tm`` and
|
||||||
points.
|
not durations or time points.
|
||||||
|
|
||||||
.. _formatexamples:
|
.. _formatexamples:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user