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