forked from syswonder/ruxos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
39 lines (30 loc) · 786 Bytes
/
main.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
#include <stdio.h>
#include <sys/time.h>
int main()
{
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0 ) {
perror("gettimeofday");
return -1;
}
printf("now time: %ld : %ld\n", tv.tv_sec,tv.tv_usec);
usleep(3000000);
if (gettimeofday(&tv, NULL) != 0 ) {
perror("gettimeofday");
return -1;
}
printf("now time: %ld : %ld\n", tv.tv_sec,tv.tv_usec);
struct timeval new_time;
new_time.tv_sec = 1731110400;
new_time.tv_usec = 0;
if (settimeofday(&new_time, NULL) != 0 ) {
perror("settimeofday");
return -1;
}
if (gettimeofday(&tv, NULL) != 0 ) {
perror("gettimeofday");
return -1;
}
printf("now time: %ld : %ld\n", tv.tv_sec,tv.tv_usec);
return 0;
}