datetime library  v0.60.0
Collection of convenience functions for timekeeping applications
datetime.h
Go to the documentation of this file.
1 
17  //
18 
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 } datetime;
63 
64 
72 void dt_run(datetime dt);
73 
78 void dt_end();
79 
89 void dt_set(datetime dt);
90 
100 
109 int dt_getms();
110 
120 int dt_toEt(datetime dt);
121 
130 datetime dt_fromEt(int et);
131 
140 void dt_toDateStr(datetime dt, char *s);
141 
150 void dt_toTimeStr(datetime dt, char *s);
151 
166 datetime dt_fromDateStr(datetime dt, char *s);
167 
182 datetime dt_fromTimeStr(datetime dt, char *s);
183 
184 #ifndef DOXYGEN_SHOULD_SKIP_THIS
185 
186  #ifndef _eunix
187  #define _eunix 2440588
188  #endif
189 
190  #ifndef _edos
191  #define _edos 2444240
192  #endif
193 
194  #ifndef _eunix
195  #define _eunix 2440588
196  #endif
197 
198  #ifndef _eprop
199  #define _eprop 2451545
200  #endif
201 
202  #ifndef _epoch
203  #define _epoch _eunix
204  #endif
205 
206  void secondctr(void *par);
207 
208  int dte_toJD(int y, int m, int d);
209  int dte_toSPD(int h, int m, int s);
210  int dte_toCal(int jd);
211  int dte_dateETV(int etv);
212  int dte_timeETV(int etv);
213  //int dte_toETV(int y, int mo, int d,int h,int m, int s);
214 
215 #endif // DOXYGEN_SHOULD_SKIP_THIS
216 
217 #if defined(__cplusplus)
218 }
219 #endif
220 /* __cplusplus */
221 #endif
222 /* DATETIME_H */
223 
224 /*
225  TERMS OF USE: MIT License
226 
227  Permission is hereby granted, free of charge, to any person obtaining a
228  copy of this software and associated documentation files (the "Software"),
229  to deal in the Software without restriction, including without limitation
230  the rights to use, copy, modify, merge, publish, distribute, sublicense,
231  and/or sell copies of the Software, and to permit persons to whom the
232  Software is furnished to do so, subject to the following conditions:
233 
234  The above copyright notice and this permission notice shall be included in
235  all copies or substantial portions of the Software.
236 
237  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
238  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
239  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
240  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
241  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
242  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
243  DEALINGS IN THE SOFTWARE.
244 */
245