FreeCalypso > hg > fc-sim-sniff
diff sw/sniff-rx/datetime.c @ 22:b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 22 Aug 2023 06:16:44 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sw/sniff-rx/datetime.c Tue Aug 22 06:16:44 2023 +0000 @@ -0,0 +1,30 @@ +/* + * Some date and time handling functions for simtrace3-sniff-rx. + */ + +#include <sys/time.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <time.h> + +extern FILE *main_outf; +extern struct timeval curtime; + +struct tm *cur_tm; + +static struct tm last_tm; + +void +current_date_time() +{ + cur_tm = gmtime(&curtime.tv_sec); + if (cur_tm->tm_year != last_tm.tm_year || + cur_tm->tm_mon != last_tm.tm_mon || + cur_tm->tm_mday != last_tm.tm_mday) + fprintf(main_outf, "%d-%02d-%02d (gmtime):\n", + cur_tm->tm_year + 1900, cur_tm->tm_mon + 1, + cur_tm->tm_mday); + bcopy(cur_tm, &last_tm, sizeof(struct tm)); +}