// Time Zones // // Douglas Thrift // // $Id$ #include "TimeZones.hpp" int main(int argc, char* argv[]) { TimeZones zones; return 0; } TimeZones::TimeZones() { time(&now); display(); } void TimeZones::display() { cout << "Content-Type: text/html\n\n"; struct tm* gmt = gmtime(&now); char date[61]; strftime(date, 61, "%A, %B %e, %Y %l:%M:%S %p %Z", gmt); cout << "Greenwich, England" << date << "\n"; list > zones; ifstream fin("timezones.dat"); while (fin.good()) { string location, zone; getline(fin, location, '='); getline(fin, zone); if (zone != "") zones.push_back(pair(location, zone)); } fin.close(); for (list >::iterator itor = zones.begin(); itor != zones.end(); itor++) { display(itor->first, itor->second); } } void TimeZones::display(const string& location, const string& zone) { sputenv("TZ=" + zone); tzset(); struct tm* when = localtime(&now); char date[61]; strftime(date, 61, "%A, %B %e, %Y %l:%M:%S %p %Z", when); cout << "" << location << "" << date << "\n"; }