PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
qsastimeP.h
Go to the documentation of this file.
1 #ifndef _QSASTIMEP_H_
2 #define _QSASTIMEP_H_
3 
4 // Declaration of private structures within libqsastime which the user does
5 // not need to acccess.
6 // Also definition of functions within libqsastime that are needed
7 // for testing of libqsastime, but which are not normally needed for anything
8 // else
9 
10 #include "qsastime.h"
11 
12 typedef struct MJDtimeStruct
13 {
14  //
15  // MJD starts at 0h, so truncating MJD always gives the same day whatever the time (unlike JD).
16  // The MJD base day is arbitrary, i.e. seconds can be greater than one day or even negative.
17  //
18 
19  int base_day; // integer part of MJD used as default
20  double time_sec; // seconds from start of base_day
21 }MJDtime;
22 
24 {
25  // Values used to define the transformation between broken down time
26  // and continuous time for the public API of libqsastime,
27  // continuous_time_qsas, broken_down_time_qsas, and strfqsas.
28 
29  // scale multiplies the continuous time variable to convert the units to
30  // days.
31  double scale;
32 
33  // offset1 and offset2 (in days) specifies the amount to add to the
34  // scaled continuous time to derive the MJD time value that is used
35  // internally by libqsastime. Normally epoch1 is an integral
36  // value (which can be exactly stored in a double for a very wide
37  // range of integers) and offset2 is normally a non-integral value
38  // whose absolute value is less than 1. This arrangement allows the
39  // continuous time variable in the API to be stored as a single double
40  // without compromising numerical precision if epoch1 and epoch2
41  // are chosen wisely.
42  double offset1, offset2;
43 
44  // The various bits of ccontrol are used as independent switches to
45  // control optional additional corrections which define the
46  // transformation between continuous time and broken-down time.
47  //
48  // If bit 0 (the lowest order bit of ccontrol) is 1 the Julian
49  // proleptic calendar is used for broken-down time. Otherwise the
50  // Gregorian proleptic calendar is used for broken-down time.
51  //
52  // If bit 1 is 1, an additional correction for the difference
53  // between atomic-clock based times and UTC is applied to the broken-down
54  // times.
55  //
56  // We reserve other bits of ccontrol for future use.
57  int ccontrol;
58  // index keeps track of latest bhunt_search index.
59  int index;
60 };
61 
62 // Set if the qsastime library is being tested.
63 /* #undef TEST_QSASTIME */
64 
65 #ifdef TEST_QSASTIME
66 #define QSASTIME_static
67 #else
68 #define QSASTIME_static static
69 #endif
70 
71 QSASTIME_static void bhunt_search( const void *key, const void *base, int n, size_t size, int *low, int ( *ge )( const void *keyval, const void *datum ) );
72 
73 QSASTIME_static int setFromUT( int year, int month, int day, int hour, int min, double sec, MJDtime *MJD, int forceJulian );
74 QSASTIME_static void breakDownMJD( int *year, int *month, int *day, int *hour, int *min, double *sec, const MJDtime *MJD, int forceJulian );
75 QSASTIME_static size_t strfMJD( char * buf, size_t len, const char *format, const MJDtime *MJD, int forceJulian, int if60secformat );
77 QSASTIME_static const char * getDayOfWeek( const MJDtime *MJD );
78 QSASTIME_static const char * getLongDayOfWeek( const MJDtime *MJD );
79 QSASTIME_static const char * getMonth( int m );
80 QSASTIME_static const char * getLongMonth( int m );
81 QSASTIME_static void getYAD( int *year, int *ifleapyear, int *doy, const MJDtime *MJD, int forceJulian );
82 
83 #endif