fix for displaying the same time two times

This commit is contained in:
randomuser 2020-10-24 21:48:35 -05:00
parent a1ecf7e2b8
commit 3f2968789b
1 changed files with 23 additions and 11 deletions

34
main.c
View File

@ -3,11 +3,6 @@
#include <time.h>
#include <signal.h>
time_t buf;
struct tm bt;
struct tm et;
int flg = 1;
struct time {
int hour;
int min;
@ -17,11 +12,24 @@ struct date {
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 time time, int minutes);
int writeData(int fd, struct session session);
struct time timediff(struct tm f, struct tm l) {
struct time tmp;
@ -31,13 +39,17 @@ struct time timediff(struct tm f, struct tm l) {
}
int main(int argc, char **argv) {
if(argc == 1) {
buf = time(NULL);
bt = *localtime(&buf);
}
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();
printf("exiting lol\n";
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;
}