fix for displaying the same time two times
This commit is contained in:
parent
a1ecf7e2b8
commit
3f2968789b
34
main.c
34
main.c
@ -3,11 +3,6 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
time_t buf;
|
|
||||||
struct tm bt;
|
|
||||||
struct tm et;
|
|
||||||
int flg = 1;
|
|
||||||
|
|
||||||
struct time {
|
struct time {
|
||||||
int hour;
|
int hour;
|
||||||
int min;
|
int min;
|
||||||
@ -17,11 +12,24 @@ struct date {
|
|||||||
int month;
|
int month;
|
||||||
int day;
|
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 sighnd() { flg = 0; }
|
||||||
void flgwt() { while(flg) { continue; } }
|
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 timediff(struct tm f, struct tm l) {
|
||||||
struct time tmp;
|
struct time tmp;
|
||||||
@ -31,13 +39,17 @@ struct time timediff(struct tm f, struct tm l) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if(argc == 1) {
|
buf = time(NULL);
|
||||||
buf = time(NULL);
|
bt = *localtime(&buf);
|
||||||
bt = *localtime(&buf);
|
|
||||||
}
|
|
||||||
printf("%d:%02d:%02d\n", bt.tm_hour, bt.tm_min, bt.tm_year + 1900);
|
printf("%d:%02d:%02d\n", bt.tm_hour, bt.tm_min, bt.tm_year + 1900);
|
||||||
|
|
||||||
signal(SIGINT, sighnd);
|
signal(SIGINT, sighnd);
|
||||||
flgwt();
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user