simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
Timestamp.h
1 using namespace std;
2 
3 //__________________________________________________________________________________________________________________________
5 string GetTimeStamp(tm * tm_local)
6 {
10 
11  string date = to_string(tm_local->tm_year+1900) + "-" + to_string(tm_local->tm_mon+1) + "-" + to_string(tm_local->tm_mday);
12 
13  // int HawaiiOffset = 10;
14  // int hour = tm_local->tm_hour;
15  // if (hour < 10){}
16 
17  string hour = to_string(tm_local->tm_hour);
18  if (hour.length() == 1) hour = "0" + hour;
19 
20  string min = to_string(tm_local->tm_min);
21  if (min.length() == 1) min = "0" + min;
22 
23  string sec = to_string(tm_local->tm_sec);
24  if (sec.length() == 1) sec = "0" + sec;
25 
26  string time = hour + ":" + min + ":" + sec;
27  string datetime = date + " " + time; //[UTC], [HI]
28  return datetime;
29 }
30 
31 
32 
33 
34 //__________________________________________________________________________________________________________________________
36 string GetDateTime()
37 {
39  time_t time_now;
40  time_now = time(NULL);
41 
42  tm * tm_local = localtime(&time_now);
43  return GetTimeStamp(tm_local);
44 }