-
Notifications
You must be signed in to change notification settings - Fork 3
/
converter.c
59 lines (51 loc) · 793 Bytes
/
converter.c
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
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "tai.h"
#include "caltime.h"
/**
*
*
*/
static void usage()
{
struct tai t;
tai_now(&t);
printf("converter taiToIso|isoToTai tai|iso\n");
printf("Current TAI: %lld\n", t.x);
}
/**
*
*
*/
int main(int argc, char** argv)
{
const char* cmd;
uint64_t tai;
const char* iso;
if (argc < 3) {
usage();
return(1);
}
cmd = argv[1];
if (strcmp(cmd, "taiToIso") == 0) {
struct caltime ct;
struct tai t;
char buf[128];
int len;
tai = _strtoui64(argv[2], NULL, 10);
t.x = tai;
caltime_utc(&ct, &t, 0, 0);
len = caltime_fmt(buf, &ct);
buf[len] = '\0';
printf("ISO: %s\n", buf);
}
else if (strcmp(cmd, "isoToTai") == 0) {
iso = argv[2];
}
else {
usage();
return(1);
}
return(0);
}