[220] | 1 | /* ------ 1) Declaration de structure temps et date ----- */
|
---|
| 2 | /* Reza 92/93 */
|
---|
| 3 |
|
---|
| 4 | #ifndef DATIME_H_SEEN
|
---|
| 5 | #define DATIME_H_SEEN
|
---|
| 6 |
|
---|
| 7 | #ifdef __cplusplus
|
---|
| 8 | extern "C" {
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | typedef struct
|
---|
| 13 | {
|
---|
| 14 | int Jour;
|
---|
| 15 | int Mois;
|
---|
| 16 | int Annee;
|
---|
| 17 | } JMA ;
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | typedef struct
|
---|
| 21 | {
|
---|
| 22 | int Heures;
|
---|
| 23 | int Minutes;
|
---|
| 24 | double Secondes;
|
---|
| 25 | } HMS ;
|
---|
| 26 |
|
---|
| 27 | /* ---------- 2) Donnees constantes ---------- */
|
---|
| 28 | #ifdef DATIMEPRIVEE
|
---|
| 29 | /* Noms des jours de la semaine - des mois */
|
---|
| 30 | char *NomJo[7] = {"Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"};
|
---|
| 31 | char *NomMo[12] =
|
---|
| 32 | {"Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet",
|
---|
| 33 | "Aout","Septembre","Octobre","Novembre","Decembre"};
|
---|
| 34 |
|
---|
| 35 | /* Nombre de jours des mois */
|
---|
| 36 | static int NbJoMois[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
|
---|
| 37 |
|
---|
| 38 | #else
|
---|
| 39 |
|
---|
| 40 | extern char *NomJo[7];
|
---|
| 41 | extern char *NomMo[12];
|
---|
| 42 |
|
---|
| 43 | #endif
|
---|
| 44 |
|
---|
| 45 | /* ------ 3) Macro de manipulation de date et heure ------- */
|
---|
| 46 |
|
---|
| 47 | #define NomJour(d) (NomJo[NumJour(d)-1])
|
---|
| 48 | #define NomMois(d) (NomMo[d.Mois-1])
|
---|
| 49 |
|
---|
| 50 | /* Chaine de forme hh:mm:sec <-> structure HMS */
|
---|
| 51 | #define StrgtoHMS(s,h) ( sscanf(s,"%d:%d:%lf", &(h.Heures),&(h.Minutes),&(h.Secondes)) )
|
---|
| 52 | #define HMStoStrg(h,s) ( sprintf(s,"%02d:%02d:%02.0f", h.Heures,h.Minutes,h.Secondes) )
|
---|
| 53 |
|
---|
| 54 | /* Chaine de forme jj/mm/aa <-> structure JMA */
|
---|
| 55 | /* EA 140998, machin infame pour que ca marche pour 1998/09/14... Pourquoi avoir fait */
|
---|
| 56 | /* des macros ??????????????????????????????????????????????????????????????????????? */
|
---|
| 57 | #define StrgtoJMA(strg,j) ( sscanf(strg,"%d/%d/%d", &(j.Jour),&(j.Mois),&(j.Annee)),\
|
---|
| 58 | (j.Jour>1900 ? sscanf(strg,"%d/%d/%d", &(j.Annee),&(j.Mois),&(j.Jour)) : 1) )
|
---|
| 59 |
|
---|
| 60 | #define JMAtoStrg(j,strg) ( sprintf(strg,"%02d/%02d/%4d", j.Jour,j.Mois,j.Annee) )
|
---|
| 61 | #define JMAtoStrgLong(j,strg) ( sprintf(strg,"%s , %d %s %d", NomJo[NumJour(j)-1], j.Jour, NomMo[j.Mois-1], j.Annee) )
|
---|
| 62 |
|
---|
| 63 | #define HtoSec(h) (h*3600.)
|
---|
| 64 | #define SectoHMS(s) ( HtoHMS(s/3600.) )
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 | #define TLegtoTSolM(d,h) ( TUtoTSolM(TLegtoTU(d,h)) )
|
---|
| 68 |
|
---|
| 69 | /* ------- 4) Declaration des fonctions ---------- */
|
---|
| 70 |
|
---|
| 71 | void StrtoHMS(char *s,HMS* hms);
|
---|
| 72 | void HMStoStr(HMS hms,char *s);
|
---|
| 73 |
|
---|
| 74 | int NbJourMois(int a, int m);
|
---|
| 75 | long JMAtoJ(JMA jma);
|
---|
| 76 | JMA JtoJMA(long j);
|
---|
| 77 | int NumJour(JMA jma);
|
---|
| 78 | JMA JsmmaatoJMA(int jj, int mm, int aa);
|
---|
| 79 | JMA JApmmaatoJMA(int nj, int mm, int aa);
|
---|
| 80 |
|
---|
| 81 | double HMStoH(HMS hms);
|
---|
| 82 | double HMStoSec(HMS hms);
|
---|
| 83 |
|
---|
| 84 | long DatetoSec(char const* date, char const* heure);
|
---|
| 85 | long DatetoSecOff(char const* date, char const* heure);
|
---|
| 86 |
|
---|
| 87 | HMS HtoHMS(double h);
|
---|
| 88 | HMS DtoDMS(double h);
|
---|
| 89 | HMS DoubletoHMS(double h);
|
---|
| 90 |
|
---|
| 91 | void SetTSolMOff(double tsmoff, char *name);
|
---|
| 92 | void PrtTSolMOff(void);
|
---|
| 93 | int SetTLegOff(char *dtz, char* dhz);
|
---|
| 94 | void PrtTLegInfo(int aa);
|
---|
| 95 | int TLegOffset(JMA date, HMS heure);
|
---|
| 96 |
|
---|
| 97 | HMS TLegtoTU(JMA date, HMS TLeg);
|
---|
| 98 | HMS TUtoTLeg(JMA date, HMS TLeg);
|
---|
| 99 | HMS TUtoTSolM(HMS TU);
|
---|
| 100 | HMS TLegtoTSid(JMA date, HMS TLeg);
|
---|
| 101 | HMS GMST_at_0h_UT(JMA date);
|
---|
| 102 | HMS TUtoTSid(JMA date, HMS TU);
|
---|
| 103 | int TSidtoTU(JMA date, HMS TS, HMS *TU1, HMS *TU2);
|
---|
| 104 | void TSidSetupLaSilla(void);
|
---|
| 105 |
|
---|
| 106 | double ToJulianDay(JMA dateTU, HMS hmsTU);
|
---|
| 107 | int FromJulianDay(double JD,JMA* dateTU, HMS* hmsTU);
|
---|
| 108 |
|
---|
| 109 | double StrgtoDegDec(char *strg);
|
---|
| 110 | char * DegDectoStrg(double deg, char *strg);
|
---|
| 111 |
|
---|
| 112 | double EccEarth(JMA dateTU);
|
---|
| 113 | double ObliqEarth(JMA dateTU);
|
---|
| 114 | double LongEcPerihelie(JMA dateTU);
|
---|
| 115 | void EquatToEclip(double alpha,double delta,double* l,double *b,JMA dateTU);
|
---|
| 116 |
|
---|
| 117 | /* ------------------------------------------------------- */
|
---|
| 118 |
|
---|
| 119 | #ifdef __cplusplus
|
---|
| 120 | }
|
---|
| 121 | #endif
|
---|
| 122 |
|
---|
| 123 | #endif
|
---|
| 124 |
|
---|
| 125 |
|
---|