#include <xtd/console>
#include <xtd/date_time>
#include <xtd/environment>
#include <xtd/format>
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) <<
" │ {:a} │ " << format(
"{:a}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:b} │ " << format(
"{:b}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:B} │ " << format(
"{:B}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:c} │ " << format(
"{:c}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:C} │ " << format(
"{:C}", 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) <<
" │ {:e} │ " << format(
"{:e}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:E} │ " << format(
"{:E}", 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) <<
" │ {:h} │ " << format(
"{:h}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:H} │ " << format(
"{:H}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:i} │ " << format(
"{:i}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:I} │ " << format(
"{:I}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:j} │ " << format(
"{:j}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:J} │ " << format(
"{:J}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:k} │ " << format(
"{:k}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:K} │ " << format(
"{:K}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:l} │ " << format(
"{:l}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:L} │ " << format(
"{:L}", 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) <<
" │ {:n} │ " << format(
"{:n}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:n} │ " << format(
"{:N}", 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) <<
" │ {:p} │ " << format(
"{:p}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:P} │ " << format(
"{:P}", 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) <<
" │ {: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) <<
" │ {:v} │ " << format(
"{:v}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:V} │ " << format(
"{:V}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:w} │ " << format(
"{:w}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:W} │ " << format(
"{:W}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:x} │ " << format(
"{:x}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:X} │ " << format(
"{:X}", 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) <<
" │ {:z} │ " << format(
"{:z}", value).
pad_right(40) <<
" │" << environment::new_line;
console::out <<
"│ " << text.pad_right(37) <<
" │ {:Z} │ " << format(
"{:Z}", 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:1589
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10