-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeFormatter.cpp
More file actions
78 lines (57 loc) · 2 KB
/
timeFormatter.cpp
File metadata and controls
78 lines (57 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <sys/time.h>
#include "timeFormatter.h"
/*****************************************************
Project [AAIGF]
FileName [time]
Author [Sina Boroumand]
Affilation [UT DSD Lab]
Date [November 03, 2016]
*****************************************************/
double timeGetTime() {
struct timeval time;
struct timezone zone;
gettimeofday(&time, &zone);
return time.tv_sec + time.tv_usec * 1e-6;
}
/////////////////////////////////////////////////////////////////////////////////////////////
const string currentDateTimeLog(string outputPortName, string modelName) {
time_t now = time(0);
struct tm tstruct;
string tempString = "";
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y%m%d_%H%M%S.log", &tstruct);
tempString = modelName + "_" + outputPortName + buf;
return tempString;
}
/////////////////////////////////////////////////////////////////////////////////////////////
const string currentDateTime() {
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tstruct);
return buf;
}
/////////////////////////////////////////////////////////////////////////////////////////////
const string currentDateTimeLog(string modelName) {
time_t now = time(0);
struct tm tstruct;
string tempString = "";
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y%m%d_%H%M%S.log", &tstruct);
tempString = modelName + "_" + buf;
return tempString;
}
/////////////////////////////////////////////////////////////////////////////////////////////
const string currectDateTimePath(string modelName) {
time_t now = time(0);
struct tm tstruct;
string tempString = "";
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%b-%Y-%d_%H-%M-%S", &tstruct);
tempString = modelName + "_" + buf;
return tempString;
}