BRL-CAD
bu_date-time.c
Go to the documentation of this file.
1 /* B U _ D A T E - T I M E . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 #include "bu.h"
22 
23 
24 int
25 main(int argc, char **argv)
26 {
27  struct bu_vls result = BU_VLS_INIT_ZERO;
28  int64_t curr_time;
29  int function_num;
30  if (argc != 2)
31  bu_exit(1, "ERROR: wrong number of parameters");
32  sscanf(argv[1], "%d", &function_num);
33  switch (function_num) {
34  case 1:
35  curr_time = 1087449261LL;
36  bu_utctime(&result, curr_time);
37  if (!BU_STR_EQUAL(result.vls_str, "2004-06-17T05:14:21Z"))
38  return 1;
39  break;
40  case 2:
41  curr_time = 631152000LL;
42  bu_utctime(&result, curr_time);
43  if (!BU_STR_EQUAL(result.vls_str, "1990-01-01T00:00:00Z"))
44  return 1;
45  break;
46  case 3:
47  curr_time = 936860949LL;
48  bu_utctime(&result, curr_time);
49  if (!BU_STR_EQUAL(result.vls_str, "1999-09-09T07:09:09Z"))
50  return 1;
51  break;
52  case 4:
53  curr_time = 1388696601LL;
54  bu_utctime(&result, curr_time);
55  if (!BU_STR_EQUAL(result.vls_str, "2014-01-02T21:03:21Z"))
56  return 1;
57  break;
58  case 5:
59  curr_time = 0LL;
60  bu_utctime(&result, curr_time);
61  if (!BU_STR_EQUAL(result.vls_str, "1970-01-01T00:00:00Z"))
62  return 1;
63  break;
64  case 6:
65  curr_time = 1LL;
66  bu_utctime(&result, curr_time);
67  if (!BU_STR_EQUAL(result.vls_str, "1970-01-01T00:00:01Z"))
68  return 1;
69  break;
70  case 7:
71  curr_time = 1431482805LL;
72  bu_utctime(&result, curr_time);
73  if (!BU_STR_EQUAL(result.vls_str, "2015-05-13T02:06:45Z"))
74  return 1;
75  break;
76  case 8:
77  curr_time = 2147483647LL;
78  bu_utctime(&result, curr_time);
79  if (!BU_STR_EQUAL(result.vls_str, "2038-01-19T03:14:07Z"))
80  return 1;
81  break;
82  case 9:
83  curr_time = 2147483649LL;
84  bu_utctime(&result, curr_time);
85  if (!BU_STR_EQUAL(result.vls_str, "2038-01-19T03:14:09Z"))
86  return 1;
87  break;
88  case 10:
89  curr_time = 3147483649LL;
90  bu_utctime(&result, curr_time);
91  if (!BU_STR_EQUAL(result.vls_str, "2069-09-27T05:00:49Z"))
92  return 1;
93  break;
94 
95  }
96  return 0;
97 }
98 
99 
100 /*
101  * Local Variables:
102  * mode: C
103  * tab-width: 8
104  * indent-tabs-mode: t
105  * c-file-style: "stroustrup"
106  * End:
107  * ex: shiftwidth=4 tabstop=8
108  */
void bu_exit(int status, const char *fmt,...) _BU_ATTR_NORETURN _BU_ATTR_PRINTF23
Definition: bomb.c:195
void bu_utctime(struct bu_vls *utc_result, const int64_t time_val)
Definition: date-time.c:33
int main(int argc, char **argv)
Definition: bu_date-time.c:25
char * vls_str
Definition: vls.h:58
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
Definition: vls.h:56
#define BU_STR_EQUAL(s1, s2)
Definition: str.h:126