ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/TimeZones/TimeZones.cpp
(Generate patch)

Comparing TimeZones/TimeZones.cpp (file contents):
Revision 53 by Douglas Thrift, 2003-12-12T14:37:48-08:00 vs.
Revision 55 by Douglas Thrift, 2003-12-14T15:24:18-08:00

# Line 15 | Line 15 | int main(int argc, char* argv[])
15  
16   TimeZones::TimeZones()
17   {
18 <        //
18 >        time(&now);
19 >        display();
20 > }
21 >
22 > void TimeZones::display()
23 > {
24 >        cout << "Content-Type: text/html\n\n";
25 >
26 >        struct tm* gmt = gmtime(&now);
27 >        char date[61];
28 >
29 >        strftime(date, 61, "%A, %B %e,&nbsp;%Y %l:%M:%S&nbsp;%p&nbsp;%Z", gmt);
30 >
31 >        cout << "<tr><td>Greenwich, England</td><td>" << date << "</td>\n";
32 >
33 >        list<pair<string, string> > zones;
34 >        ifstream fin("timezones.dat");
35 >
36 >        while (fin.good())
37 >        {
38 >                string location, zone;
39 >
40 >                getline(fin, location, '=');
41 >                getline(fin, zone);
42 >
43 >                if (zone != "") zones.push_back(pair<string, string>(location, zone));
44 >        }
45 >
46 >        fin.close();
47 >
48 >        for (list<pair<string, string> >::iterator itor = zones.begin(); itor !=
49 >                zones.end(); itor++)
50 >        {
51 >                display(itor->first, itor->second);
52 >        }
53 > }
54 >
55 > void TimeZones::display(const string& location, const string& zone)
56 > {
57 >        sputenv("TZ=" + zone);
58 >        tzset();
59 >        
60 >        struct tm* when = localtime(&now);
61 >        char date[61];
62 >
63 >        strftime(date, 61, "%A, %B %e,&nbsp;%Y %l:%M:%S&nbsp;%p&nbsp;%Z", when);
64 >
65 >        cout << "<tr><td>" << location << "</td><td>" << date << "</td></tr>\n";
66   }

Comparing TimeZones/TimeZones.cpp (property svn:eol-style):
Revision 53 by Douglas Thrift, 2003-12-12T14:37:48-08:00 vs.
Revision 55 by Douglas Thrift, 2003-12-14T15:24:18-08:00

# Line 0 | Line 1
1 + native

Comparing TimeZones/TimeZones.cpp (property svn:keywords):
Revision 53 by Douglas Thrift, 2003-12-12T14:37:48-08:00 vs.
Revision 55 by Douglas Thrift, 2003-12-14T15:24:18-08:00

# Line 0 | Line 1
1 + Id

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines