source: Sophya/trunk/SophyaLib/NTools/datime.h@ 3865

Last change on this file since 3865 was 3018, checked in by ansari, 19 years ago

Adaptation modification SophyaInitiator/ enregistrement module NTools + petite correction ds commentaire - pret pour tag V2 Reza 17/7/2006

File size: 4.1 KB
RevLine 
[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
8extern "C" {
9#endif
10
11
[2808]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) */
[220]22typedef struct
23 {
24 int Jour;
25 int Mois;
26 int Annee;
27 } JMA ;
28
[2808]29/*!
30 \ingroup NTools
31 \brief Structure HMS pour representer une heure (Heure, Minute Seconde)
32*/
[220]33typedef struct
34 {
35 int Heures;
36 int Minutes;
37 double Secondes;
38 } HMS ;
39
[3018]40/* \cond */
[220]41/* ---------- 2) Donnees constantes ---------- */
42#ifdef DATIMEPRIVEE
43/* Noms des jours de la semaine - des mois */
44char *NomJo[7] = {"Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"};
45char *NomMo[12] =
46 {"Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet",
47 "Aout","Septembre","Octobre","Novembre","Decembre"};
48
49/* Nombre de jours des mois */
50static int NbJoMois[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
51
52#else
53
54extern char *NomJo[7];
55extern char *NomMo[12];
56
57#endif
58
[2808]59/* \endcond */
[220]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
[2808]64/* Chaine de forme hh:mm:sec <-> structure HMS */
65/*! \brief Decodage de Chaine de forme hh:mm:sec -> structure HMS */
[220]66#define StrgtoHMS(s,h) ( sscanf(s,"%d:%d:%lf", &(h.Heures),&(h.Minutes),&(h.Secondes)) )
[2808]67/*! \brief structure HMS -> Chaine de forme hh:mm:sec */
[220]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 ??????????????????????????????????????????????????????????????????????? */
[2808]73/*! \brief Chaine de caracteres sous forme de dd/mm/aaaa -> structure JMA jma. */
[220]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) )
[2808]76/*! \brief structure JMA -> Chaine de forme jj/mm/aa */
[220]77#define JMAtoStrg(j,strg) ( sprintf(strg,"%02d/%02d/%4d", j.Jour,j.Mois,j.Annee) )
[2808]78/*! \brief structure JMA -> Chaine de forme jj/mm/aa */
[220]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
89void StrtoHMS(char *s,HMS* hms);
90void HMStoStr(HMS hms,char *s);
91
92int NbJourMois(int a, int m);
93long JMAtoJ(JMA jma);
94JMA JtoJMA(long j);
95int NumJour(JMA jma);
96JMA JsmmaatoJMA(int jj, int mm, int aa);
97JMA JApmmaatoJMA(int nj, int mm, int aa);
98
99double HMStoH(HMS hms);
100double HMStoSec(HMS hms);
101
102long DatetoSec(char const* date, char const* heure);
103long DatetoSecOff(char const* date, char const* heure);
104
105HMS HtoHMS(double h);
106HMS DtoDMS(double h);
107HMS DoubletoHMS(double h);
108
109void SetTSolMOff(double tsmoff, char *name);
110void PrtTSolMOff(void);
111int SetTLegOff(char *dtz, char* dhz);
112void PrtTLegInfo(int aa);
113int TLegOffset(JMA date, HMS heure);
114
115HMS TLegtoTU(JMA date, HMS TLeg);
116HMS TUtoTLeg(JMA date, HMS TLeg);
117HMS TUtoTSolM(HMS TU);
118HMS TLegtoTSid(JMA date, HMS TLeg);
119HMS GMST_at_0h_UT(JMA date);
120HMS TUtoTSid(JMA date, HMS TU);
121int TSidtoTU(JMA date, HMS TS, HMS *TU1, HMS *TU2);
122void TSidSetupLaSilla(void);
123
124double ToJulianDay(JMA dateTU, HMS hmsTU);
125int FromJulianDay(double JD,JMA* dateTU, HMS* hmsTU);
126
127double StrgtoDegDec(char *strg);
128char * DegDectoStrg(double deg, char *strg);
129
130double EccEarth(JMA dateTU);
131double ObliqEarth(JMA dateTU);
132double LongEcPerihelie(JMA dateTU);
133void 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
Note: See TracBrowser for help on using the repository browser.