-
Notifications
You must be signed in to change notification settings - Fork 162
/
Time.c
42 lines (34 loc) · 951 Bytes
/
Time.c
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
#include <stdio.h>
#include <sys\timeb.h>
int main() {
struct timeb start, end;
int diff;
int i = 0;
ftime(&start);
while(i++ < 999) {
/*gastando tempo*/
printf(".");
}
ftime(&end);
diff = (int) (1000.0 * (end.time - start.time) + (end.millitm - start.millitm));
printf("\nGastou %u milisegundos\n", diff);
return 0;
}
//É possível destrinchar o timeb.
void getCurrTimeString(TCHAR* mytime) {
_timeb myTime;
struct tm * timeinfo;
_ftime64_s( &myTime );
time_t rawtime = myTime.time;
unsigned short myMillis = myTime.millitm;
timeinfo = localtime ( &rawtime );
_stprintf(mytime,_T("%d-%02d-%02dT%02d:%02d:%02d.%03d"),
(1900+timeinfo->tm_year),
(timeinfo->tm_mon+1),
timeinfo->tm_mday,
timeinfo->tm_hour,
timeinfo->tm_min,
timeinfo->tm_sec,
myMillis);
}
//https://pt.stackoverflow.com/q/39200/101