56 lines
1.1 KiB
C
56 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <signal.h>
|
|
|
|
struct time {
|
|
int hour;
|
|
int min;
|
|
};
|
|
struct date {
|
|
int year;
|
|
int month;
|
|
int day;
|
|
};
|
|
struct session {
|
|
struct date date;
|
|
struct time time;
|
|
int minutes;
|
|
char *name;
|
|
};
|
|
|
|
time_t buf;
|
|
struct time buf2;
|
|
struct tm bt;
|
|
struct tm et;
|
|
int flg = 1;
|
|
|
|
|
|
void sighnd() { flg = 0; }
|
|
void flgwt() { while(flg) { continue; } }
|
|
|
|
int writeData(int fd, struct session session);
|
|
|
|
struct time timediff(struct tm f, struct tm l) {
|
|
struct time tmp;
|
|
tmp.hour = f.tm_hour - l.tm_hour;
|
|
tmp.min = f.tm_min - l.tm_min;
|
|
return tmp;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
buf = time(NULL);
|
|
bt = *localtime(&buf);
|
|
printf("%d:%02d:%02d\n", bt.tm_hour, bt.tm_min, bt.tm_year + 1900);
|
|
|
|
signal(SIGINT, sighnd);
|
|
flgwt();
|
|
buf = time(NULL);
|
|
et = *localtime(&buf);
|
|
printf("%d:%02d:%02d:%02d\n", et.tm_hour, et.tm_min, et.tm_sec, et.tm_year + 1900);
|
|
buf2 = timediff(et, bt);
|
|
printf("%i:%i difference\n", buf2.hour, buf2.min);
|
|
printf("exiting lol\n");
|
|
return 0;
|
|
}
|