-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidconvert.c
More file actions
59 lines (53 loc) · 994 Bytes
/
sidconvert.c
File metadata and controls
59 lines (53 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Convert to the funky every-5-seconds format used by the stanford SID
* folks
*/
#include <stdio.h>
#include <time.h>
#define DEFAULT_RATE 5
int
main (int argc, char **argv)
{
time_t now;
long ut;
double value;
double max = -9.999e13;
double min = 9.99e13;
int samesec = -1;
int rate = DEFAULT_RATE;
if (argc > 1)
{
rate = atoi(argv[1]);
}
while (fscanf (stdin, "%ld %lf", &ut, &value) == 2)
{
struct tm *gmp;
now = (time_t) ut;
gmp = gmtime (&now);
if (samesec != gmp->tm_sec)
{
samesec = gmp->tm_sec;
if ((gmp->tm_sec % rate) == 0)
{
fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d, %f\n",
gmp->tm_year+1900,
gmp->tm_mon+1,
gmp->tm_mday,
gmp->tm_hour,
gmp->tm_min,
gmp->tm_sec, value);
if (value > max)
{
max = value;
}
if (value < min)
{
min = value;
}
}
}
}
fprintf (stdout, "MAXIMUM %f\n", max);
fprintf (stdout, "MINIMUM %f\n", min);
return (0);
}