30 static std::string
PATH_DATA=
"/home/michael/workspace_kepler/ROOT_application/data";
48 stream.getline( buf_value, 30, delim );
49 double t = std::atof(buf_value);
56 void splitline(
const std::string& str,
const std::string& delimiters , std::vector<std::string>& tokens) {
58 std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
60 std::string::size_type pos = str.find_first_of(delimiters, lastPos);
62 while (std::string::npos != pos || std::string::npos != lastPos)
65 tokens.push_back(str.substr(lastPos, pos - lastPos));
67 lastPos = str.find_first_not_of(delimiters, pos);
69 pos = str.find_first_of(delimiters, lastPos);
80 tmp_time = time ( &time_unix );
84 std::cout <<
"GetTime_tToday get actual date " << tmp_time << std::endl;
96 std::cout <<
"Entry StringToTimeT str " << str_date << std::endl;
97 std::cout <<
"Size String " << str_date.size() << std::endl;
99 std::string date_string;
104 struct tm date_tm = {0, 0, 0, 0, 0, 0, 0, 0, -1 , 0,
nullptr };
110 if ( str_date.size() == 19 ) {
111 p = strptime ( str_date.c_str(),
"%Y-%m-%d %H:%M:%S", &date_tm );
113 }
else if ( str_date.size() == 10 ) {
114 p = strptime ( str_date.c_str(),
"%Y-%m-%d", &date_tm );
118 if ( p ==
nullptr ) {
119 std::cout <<
"ERROR strptime " << std::endl;
122 return mktime( &date_tm );
128 std::cout <<
"Entry StringToTimeT with char* str:" << str << std::endl;
129 std::cout <<
"len of str " << strlen(str) << std::endl;
132 size_t str_len = strlen(str);
134 struct tm date_tm = {0, 0, 0, 0, 0, 0, 0, 0, -1 , 0,
nullptr };
140 if ( str_len == 19 ) {
141 p = strptime ( str,
"%Y-%m-%d %H:%M:%S", &date_tm );
143 }
else if ( str_len == 10 ) {
144 p = strptime ( str,
"%Y-%m-%d", &date_tm );
148 if ( p ==
nullptr ) {
149 std::cout <<
"ERROR strptime " << std::endl;
153 return mktime( &date_tm );
160 std::string date_string;
172 date_tm = localtime ( &time );
176 strftime(tmp_char,25,
"%Y-%m-%d %H:%M:%S",date_tm);
178 strftime ( tmp_char, 20,
"%Y-%m-%d", date_tm );
180 date_string.assign(tmp_char);
185 void GetDateYMD( time_t time_unix,
int &year,
int &month,
int &day ) {
187 std::cout <<
"GetDateYMD " << time_unix << std::endl;
190 struct tm * timeinfo;
194 if ( time_unix == 0 ) {
197 tmp_time = time ( &time_unix );
201 tmp_time = time_unix;
204 timeinfo = localtime ( &tmp_time );
205 year = timeinfo->tm_year + 1900 ;
206 month = timeinfo->tm_mon + 1;
207 day = timeinfo->tm_mday;
217 std::string date_string;
237 struct tm date_tm = {0, 0, 0, 0, 0, 0, 0, 0, -1 , 0,
nullptr };
241 strptime ( str_date.c_str(),
"%Y-%m-%d %H:%M:%S", &date_tm );
268 time_t ret = mktime( &date_tm );
double fromStreamToDouble(std::iostream &stream, char delim)
Read the next character of a stream as a double.
static std::string PATH_DATA
to modify before compilation to set from a Config file
void SetPathData(std::string new_path)
forced to use this function now.
Group general functions to convert to/from string, split line...
time_t GetTime_tToday()
Get the time_t of today.
const time_t ERROR_StrToTime
Error code returned by StringToTime_t if the string cannot be parsed correctly Must be a time_t...
time_t StringToTime_t_old(std::string str_date)
std::string Time_tToString(const time_t &time, const bool b_hour)
Return a string representing the date All times are expressed in the localtime.
void GetDateYMD(time_t time_unix, int &year, int &month, int &day)
Set year, month and day given an input time.
time_t StringToTime_t(const std::string &str_date)
Return the time_t from a string .
std::string GetPathData()
void splitline(const std::string &str, const std::string &delimiters, std::vector< std::string > &tokens)
splitline