#include <xtd/xtd>
enum class cap {title, middle, end};
auto print_date_time(const string& text, const date_time& value, cap c) {
if (c == cap::title)
console::out
<< "┌───────────────────────────────────────┬─────────────────────┬──────────────────────────────────────────┐" << environment::new_line
<< "│ date_time │ format │ representation │" << environment::new_line
<< "├───────────────────────────────────────┼─────────────────────┼──────────────────────────────────────────┤" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {} │ " << format(
"{}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:d} │ " << format(
"{:d}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:D} │ " << format(
"{:D}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:f} │ " << format(
"{:f}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:F} │ " << format(
"{:F}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:g} │ " << format(
"{:g}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:G} │ " << format(
"{:G}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:m} │ " << format(
"{:m}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:M} │ " << format(
"{:M}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:o} │ " << format(
"{:o}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:O} │ " << format(
"{:O}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:r} │ " << format(
"{:r}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:R} │ " << format(
"{:R}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:s} │ " << format(
"{:s}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:t} │ " << format(
"{:t}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:T} │ " << format(
"{:T}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:u} │ " << format(
"{:u}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:U} │ " << format(
"{:U}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:y} │ " << format(
"{:y}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:Y} │ " << format(
"{:Y}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:h:mm:ss.ff t} │ " << format(
"{:h:mm:ss.ff t}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:d MMM yyyy} │ " << format(
"{:d MMM yyyy}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:HH:mm:ss.f} │ " << format(
"{:HH:mm:ss.f}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:dd MMM HH:mm:ss} │ " << format(
"{:dd MMM HH:mm:ss}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:\\Mon\\t\\h\\: M} │ " << format(
"{:\\Mon\\t\\h\\: M}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:HH:mm:ss.ffffzzz} │ " << format(
"{:HH:mm:ss.ffffzzz}", value).
pad_right(40) <<
" │" << environment::new_line;
if (c != cap::end)
console::out << "├───────────────────────────────────────┼─────────────────────┼──────────────────────────────────────────┤" << environment::new_line;
else
console::out << "└───────────────────────────────────────┴─────────────────────┴──────────────────────────────────────────┘" << environment::new_line;
}
auto main() -> int {
print_date_time("date_time {}", date_time {}, cap::title);
print_date_time("date_time {123456789123456789}", date_time {123456789123456789}, cap::middle);
print_date_time("date_time {1971, 1, 5}", date_time {1971, 1, 5}, cap::middle);
print_date_time("date_time {1971, 1, 5, 21, 30, 3}", date_time {1971, 1, 5, 21, 30, 3}, cap::middle);
print_date_time("date_time {1971, 1, 5, 21, 30, 3, 42}", date_time {1971, 1, 5, 21, 30, 3, 42}, cap::middle);
print_date_time("date_time::now()", date_time::now(), cap::middle);
print_date_time("date_time::utc_now()", date_time::utc_now(), cap::middle);
print_date_time("date_time::min_value", date_time::min_value, cap::middle);
print_date_time("date_time::max_value", date_time::max_value, cap::end);
}
basic_string pad_right(xtd::size total_width) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:1540