FreeCalypso > hg > fc-sim-sniff
annotate sw/sniff-rx/datetime.c @ 57:eb4274e7f4da
simsniff-dec: decode SELECT file IDs
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 04 Oct 2023 03:54:00 +0000 |
parents | b112c2df6c43 |
children |
rev | line source |
---|---|
22
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Some date and time handling functions for simtrace3-sniff-rx. |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/time.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdlib.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <time.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 extern FILE *main_outf; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern struct timeval curtime; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 struct tm *cur_tm; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static struct tm last_tm; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 void |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 current_date_time() |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 cur_tm = gmtime(&curtime.tv_sec); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (cur_tm->tm_year != last_tm.tm_year || |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 cur_tm->tm_mon != last_tm.tm_mon || |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 cur_tm->tm_mday != last_tm.tm_mday) |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 fprintf(main_outf, "%d-%02d-%02d (gmtime):\n", |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 cur_tm->tm_year + 1900, cur_tm->tm_mon + 1, |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 cur_tm->tm_mday); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 bcopy(cur_tm, &last_tm, sizeof(struct tm)); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |