#include #include #include //for the functions time and localtime using namespace std; //Output the current local date and time. In C++11, include and //const auto now {chrono::system_clock::now()}; //const time_t t {chrono::system_clock::to_time_t(now)}; int main() { const time_t t {time(nullptr)}; const tm *const p {localtime(&t)}; cout << "t = " << t << "\n\n"; //Output the fields of the structure that p points to. //Day of week is 0 for Sunday, 1 for Monday, etc. cout << "The current year is " << p->tm_year + 1900 << ".\n"; cout << "The current month (1 to 12) is " << p->tm_mon + 1 << ".\n"; cout << "The current day (1 to 31) is " << p->tm_mday << ".\n\n"; cout << "This is day number " << p->tm_yday << " of the year.\n"; cout << "This is day number " << p->tm_wday << " of the week.\n\n"; cout << "The current hour (0 to 23) is " << p->tm_hour << ".\n"; cout << "The current minute (0 to 59) is " << p->tm_min << ".\n"; cout << "The current second (0 to 61) is " << p->tm_sec << ".\n\n"; if (p->tm_isdst >= 0) { cout << "Daylight Savings Time is "; if (p->tm_isdst == 0) { cout << "not "; } cout << "in effect.\n"; } return EXIT_SUCCESS; }