#include #include #include //for class string #include //for class system_clock #include //for the function localtime and structure tm using namespace std; int main() { const auto now {chrono::system_clock::now()}; const time_t t {chrono::system_clock::to_time_t(now)}; const tm *const p {localtime(&t)}; const int year {p->tm_year + 1900}; const int month {p->tm_mon + 1}; //in the range 1 to 12 inclusive const int day {p->tm_mday}; //in the range 1 to 31 inclusive const int weekday {p->tm_wday}; //in the range 0 (Sun) to 6 (Sat) const string dayname[] { "Sunday", //0 "Monday", //1 "Tuesday", //2 "Wednesday", //3 "Thursday", //4 "Friday", //5 "Saturday" //6 }; const string monthname[] { "", //so January will have subscript 1 "January", // 1 "February", // 2 "March", // 3 "April", // 4 "May", // 5 "June", // 6 "July", // 7 "August", // 8 "Septemper", // 9 "October", //10 "November", //11 "December" //12 }; //The CGI MIME-type header must be followed by two newlines. cout << "Content-type: text/plain\n\n"; cout << "Today is " << dayname[weekday] << ", " << monthname[month] << " " << day << ", " << year << ".\n"; return EXIT_SUCCESS; }