das2C
das core C utilities (v3)
Loading...
Searching...
No Matches
tt2000.h
Go to the documentation of this file.
1
4#ifndef _tt2000_h_
5#define _tt2000_h_
6
7#include <stdbool.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/* The UTC origin is funny due to leap seconds and makes it appear as if
14 * the TT2000 JD origin is: 2451544.9992571296296296 instead. */
15#define DAS_TT2000_JD_ORIGIN 2451545.0
16
17/* das2 TT2000 functions in general are thread-safe but the initialization
18 * function are *NOT* This is this is called from das2_init() to insure
19 * leapsecond tables are initialized before using any of the conversion
20 * functions.
21 *
22 * @warning Not thread safe
23 *
24 * NOTE: You can avoid the external leapsecond load hit on das2 startup
25 * if the environment variable: CDF_LEAPSECONDSTABLE is not defined,
26 * Though that means you have to get a new copy of the library before
27 * each leapsecond is added.
28 */
29bool das_tt2K_init(const char* sProgName);
30
37bool das_tt2k_reinit(const char* sProgName);
38
39/* Renamed CDF UTC to TT2000 handling function to avoid namespace
40 * conflicts. Roughly corresponds to computeTT2000 in original sources.
41 *
42 * Var Arg Warning! This function expects DOUBLES. Since it's a var-arg
43 * function it will accept *any* argument after the day value but it will
44 * blindly treat all arguments as doubles. Up casting will *not* be
45 * preformed! This function is legacy code from the CDF libraries.
46 * use the safer alternative:
47 *
48 * das_time dt;
49 * tt = Units_convertFromDt(&dt, UNIT_TT2000);
50 *
51 * instead. You have been warned.
52 *
53 * Thread Safety: Function is thread safe so long as das_tt2k_init() or
54 * das_tt2k_reinit() are *not* called from another thread.
55 */
56long long das_utc_to_tt2K(double year, double month, double day, ...);
57
58/* Renamed CDF TT2000 to UTC function, renamed to avoid nomespace conflicts.
59 * Corresponds to breakdownTT2000 in original sources.
60 *
61 * Var Arg Warning! This function expects DOUBLES. Since it's a var-arg
62 * function it will accept *any* argument after the day value but it will
63 * blindly treat all arguments as pointers to doubles. Up casting will
64 * *not* be preformed! This function is legacy code from the CDF libraries.
65 * use the safer alternative:
66 *
67 * das_time dt;
68 * Units_convertToDt(&dt, tt, UNIT_TT2000);
69 *
70 * instead. You have been warned.
71 *
72 * Thread Safety: Function is thread safe so long as das_tt2k_init() or
73 * das_tt2k_reinit() are *not* called from another thread.
74 */
75void das_tt2K_to_utc(
76 long long nanoSecSinceJ2000, double* ly, double* lm, double* ld, ...
77);
78
79/* Convert a UNIT_TT2000 double to UNIT_US2000 double
80 *
81 * This is a direct conversion of value on the UNIT_TT2000 scale to values on
82 * the UNIT_US2000 scale without a round trip through UTC broken out times.
83 *
84 * Used by conversion functions in units.c.
85 *
86 * WARNING: US2000 has no leap seconds so near a leap second two different
87 * TT2000 times will convert to the same US2000 time
88 *
89 * Does not check the TT2000 mutex, thread safe so long as das_tt2k_init()
90 * or das_tt2k_reinit() are not called from another thread.
91 */
92double das_tt2K_to_us2K(double tt2000);
93
94/* Convert a UNIT_US2000 double to UNIT_TT2000 double
95 *
96 * This is a direct conversion of value on the UNIT_US2000 scale to values on
97 * the UNIT_TT2000 scale without a round trip through UTC broken out times.
98 *
99 * Used by conversion functions in units.c.
100 *
101 * NOTE: Near a leap second two US2000 values that are 1 second apart will
102 * appear as 2 seconds apart on the TT2000 scale.
103 *
104 *
105 * Does not check the TT2000 mutex, thread safe so long as das_tt2k_init()
106 * or das_tt2k_reinit() are not called from another thread.
107 */
108double das_us2K_to_tt2K(double us2000);
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif /* _tt2000_h_ */
bool das_tt2k_reinit(const char *sProgName)
Re-initialize the leap second table.