-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruc_timstmp.c
More file actions
72 lines (61 loc) · 993 Bytes
/
struc_timstmp.c
File metadata and controls
72 lines (61 loc) · 993 Bytes
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
#include <stdio.h>
typedef struct timestamp
{
int date;
int month;
int year;
int hours;
int minutes;
int seconds;
}tstmp;
int compare(tstmp t1,tstmp t2){
if(t1.year>t2.year){
return 1;
}
if(t1.year<t2.year){
return -1;
}
if(t1.month>t2.month){
return 1;
}
if(t1.month<t2.month){
return -1;
}
if(t1.date>t2.date){
return 1;
}
if(t1.date<t2.date){
return -1;
}
if(t1.hours>t2.hours){
return 1;
}
if(t1.hours<t2.hours){
return -1;
}
if(t1.minutes>t2.minutes){
return 1;
}
if(t1.minutes<t2.minutes){
return -1;
}
if(t1.seconds>t2.seconds){
return 1;
}
if(t1.seconds<t2.seconds){
return -1;
}
return 0;
}
void display(tstmp t){
printf("time stamp date is %d/%d/%d time is %d-%d-%d\n",t.date,t.month,t.year,t.hours,t.minutes,t.seconds);
}
int main(){
tstmp t1 = {11,9,20,22,16,16};
tstmp t2 = {11,9,20,22,16,16};
display(t1);
display(t2);
int a = compare(t1,t2);
printf("The comparison of timestamps is %d\n",a);
return 0;
}