Add locale example

This commit is contained in:
Victor Zverovich 2020-01-20 08:42:16 -08:00
parent fd1cabe464
commit 0b2eb6501c

View File

@ -399,13 +399,15 @@ Using type-specific formatting::
fmt::print("{:%Y-%m-%d %H:%M:%S}", t); fmt::print("{:%Y-%m-%d %H:%M:%S}", t);
// Prints: 2010-08-04 12:15:58 // Prints: 2010-08-04 12:15:58
Using the comma as a thousands separator::
#include <fmt/locale.h>
auto s = fmt::format(std::locale("en_US.UTF-8"), "{:n}", 1234567890);
// s == "1,234,567,890"
.. ifconfig:: False .. ifconfig:: False
Using the comma as a thousands separator::
format("{:,}", 1234567890);
'1,234,567,890'
Nesting arguments and more complex examples:: Nesting arguments and more complex examples::
>>> for align, text in zip('<^>', ['left', 'center', 'right']): >>> for align, text in zip('<^>', ['left', 'center', 'right']):