00001 #include "asciitimestamp.h"
00002 #include <map>
00003 #include <string>
00004 #include <cstdlib>
00005
00006
00007 PHTimeStamp
00008 getTimeStamp(const char* cdate)
00009 {
00010 static std::map<std::string,int> months;
00011
00012 if (months.empty()) {
00013 months["Jan"] = 1;
00014 months["Feb"] = 2;
00015 months["Mar"] = 3;
00016 months["Apr"] = 4;
00017 months["May"] = 5;
00018 months["Jun"] = 6;
00019 months["Jul"] = 7;
00020 months["Aug"] = 8;
00021 months["Sep"] = 9;
00022 months["Oct"] = 10;
00023 months["Nov"] = 11;
00024 months["Dec"] = 12;
00025 }
00026
00027 std::string thedate(cdate);
00028
00029 std::string smonth = thedate.substr(4,3);
00030 std::string sday = thedate.substr(8,2);
00031 std::string shour = thedate.substr(11,2);
00032 std::string smin = thedate.substr(14,2);
00033 std::string ssec = thedate.substr(17,2);
00034 std::string syear = thedate.substr(20,4);
00035
00036 int year = atoi(syear.c_str());
00037 int month = months[smonth];
00038 int day = atoi(sday.c_str());
00039 int hour = atoi(shour.c_str());
00040 int min = atoi(smin.c_str());
00041 int sec = atoi(ssec.c_str());
00042
00043 return PHTimeStamp(year,month,day,hour,min,sec,0);
00044 }
00045
00046
00047 PHTimeStamp
00048 getTimeStamp(std::ifstream& in)
00049 {
00050 char thedate[200];
00051
00052 in.getline(thedate,200,'\n');
00053 return getTimeStamp(thedate);
00054 }