#include <xtd/console>
#include <xtd/date_time>
#include <xtd/startup>
class program {
public:
static auto main() {
auto save_now = date_time::now();
auto save_utc_now = date_time::utc_now();
display_now("utc_now: ...........", save_utc_now);
display_now("now: ...............", save_now);
console::write_line();
my_dt = date_time::specify_kind(save_now, date_time_kind::utc);
display("utc: ...............", my_dt);
my_dt = date_time::specify_kind(save_now, date_time_kind::local);
display("local: .............", my_dt);
my_dt = date_time::specify_kind(save_now, date_time_kind::unspecified);
display("unspecified: .......", my_dt);
}
static void display(
const string& title,
const date_time& input_dt) {
auto disp_dt = input_dt;
auto dt_string = string::empty_string;
console::write_line("{0} {1}, kind = {2}", title, dt_string, disp_dt.kind());
console::write_line(" to_local_time: {0}, kind = {1}", dt_string, disp_dt.kind());
console::write_line(" to_universal_time: {0}, kind = {1}", dt_string, disp_dt.kind());
console::write_line();
}
static void display_now(
const string& title,
const date_time& input_dt) {
console::write_line(
"{0} {1}, kind = {2}", title, dt_string, input_dt.
kind());
}
};
Represents an instant in time, typically expressed as a date and time of day.
Definition date_time.hpp:85
xtd::string to_string() const noexcept override
Converts the value of the current xtd::date_time object to its equivalent string representation using...
date_time to_universal_time() const
Converts the value of the current xtd::date_time object to Coordinated Universal Time (UTC).
date_time to_local_time() const
Converts the value of the current xtd::date_time object to local time.
date_time_kind kind() const noexcept
Gets a value that indicates whether the time represented by this instance is based on local time,...
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:175
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10