#ifndef __FormatTime_h_ #define __FormatTime_h_ // time_t is our preferred time format. That is espeically true when we share // a time value over the network. However, there is a problem. Some people // insist that the time appear on their screen in Eastern time, even though // the time on their computer is not Eastern time. It is very hard for the // client software to make this conversion. So we do the conversion on the // server. #include #include // This accepts two different formats. If it looks like a normal integer // (i.e. "1274141860") then we just convert from a string to an integer. We // assume it's a valid time_t. On the other hand, if it looks like a valid // mysql date & time (i.e. "2010-05-07 10:52:00") then we convert from that // format to time_t, and we assume the time is coming from the Eastern time // zone. If it does not look like a valid time (i.e. "") then we return 0. time_t importTime(std::string const &asString); // If forceEastern is false, we just convert the integer to a string. If // forceEastern is true, we export it in the mysql format and use eastern time. // If time_t is 0, regardless of forceEastern, we return the empty string. std::string exportTime(time_t asUnix, bool forceEastern); #endif