datetime library  v0.50.0
Collection of convenience functions for timekeeping applications
datetime.h
Go to the documentation of this file.
1 
19 #ifndef DATETIME_H
20 #define DATETIME_H
21 
22 #if defined(__cplusplus)
23 extern "C" {
24 #endif
25 
26 #ifndef SECONDS
27 
30 #define SECONDS 1
31 #endif
32 
33 #ifndef MINUTES
34 
37 #define MINUTES 60
38 #endif
39 
40 #ifndef HOURS
41 
44 #define HOURS 60 * MINUTES
45 #endif
46 
47 #ifndef DAYS
48 
51 #define DAYS 24 * HOURS
52 #endif
53 
54 typedef struct datetime_st
55 {
56  volatile int y;
57  volatile int mo;
58  volatile int d;
59  volatile int h;
60  volatile int m;
61  volatile int s;
62  volatile int etv;
63 } datetime;
64 
75 int dt_start(datetime *dts);
76 
81 void dt_stop();
82 
106 int dt_set(datetime *dt, int y, int mo, int d, int h, int m, int s);
107 
119 void dt_copy(datetime *dtDest, datetime *dtSrc);
120 
137 int dt_cmpSec(datetime *dtTarget, datetime *dtCmpVal);
138 
149 void dt_addSec(datetime *dt, int seconds);
150 
151 #ifndef DOXYGEN_SHOULD_SKIP_THIS
152 
153  #ifndef _eunix
154  #define _eunix 2440588
155  #endif
156 
157  #ifndef _edos
158  #define _edos 2444240
159  #endif
160 
161  #ifndef _eunix
162  #define _eunix 2440588
163  #endif
164 
165  #ifndef _eprop
166  #define _eprop 2451545
167  #endif
168 
169  #ifndef _epoch
170  #define _epoch _eunix
171  #endif
172 
173  int dte_toJD(int y, int m, int d);
174  int dte_toSPD(int h, int m, int s);
175  int dte_timeETV(int etv);
176  int dte_toCal(int jd);
177  int dte_dateETV(int etv);
178  int dte_toETV(int y, int mo, int d,int h,int m, int s);
179 
180 #endif // DOXYGEN_SHOULD_SKIP_THIS
181 
182 #if defined(__cplusplus)
183 }
184 #endif
185 /* __cplusplus */
186 #endif
187 /* DATETIME_H */
188 
189 /*
190  TERMS OF USE: MIT License
191 
192  Permission is hereby granted, free of charge, to any person obtaining a
193  copy of this software and associated documentation files (the "Software"),
194  to deal in the Software without restriction, including without limitation
195  the rights to use, copy, modify, merge, publish, distribute, sublicense,
196  and/or sell copies of the Software, and to permit persons to whom the
197  Software is furnished to do so, subject to the following conditions:
198 
199  The above copyright notice and this permission notice shall be included in
200  all copies or substantial portions of the Software.
201 
202  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
203  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
204  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
205  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
206  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
207  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
208  DEALINGS IN THE SOFTWARE.
209 */
210