diff --git a/doc/api.rst b/doc/api.rst index ecaa6ef0..b27f12d8 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -415,18 +415,15 @@ For example:: #include - 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`. diff --git a/doc/syntax.rst b/doc/syntax.rst index 979ca101..e4187759 100644 --- a/doc/syntax.rst +++ b/doc/syntax.rst @@ -325,9 +325,11 @@ Literal chars are copied unchanged to the output. Precision is valid only for ``std::chrono::duration`` types with a floating-point representation type. *conversion_spec* are conversion specifiers documented in `strftime -`_. Specifiers that have a -calendaric component such as `'d'` are valid only for ``std::tm`` and not -durations or time points. +`_ for ``std::tm`` and +in `Meaning of conversion specifiers ` +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 +points. .. _formatexamples: