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

Last change on this file since 753 was 220, checked in by ansari, 26 years ago

Creation module DPC/NTools Reza 09/04/99

File size: 3.4 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
12typedef struct
13 {
14 int Jour;
15 int Mois;
16 int Annee;
17 } JMA ;
18
19
20typedef 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 */
30char *NomJo[7] = {"Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi","Dimanche"};
31char *NomMo[12] =
32 {"Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet",
33 "Aout","Septembre","Octobre","Novembre","Decembre"};
34
35/* Nombre de jours des mois */
36static int NbJoMois[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
37
38#else
39
40extern char *NomJo[7];
41extern 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
71void StrtoHMS(char *s,HMS* hms);
72void HMStoStr(HMS hms,char *s);
73
74int NbJourMois(int a, int m);
75long JMAtoJ(JMA jma);
76JMA JtoJMA(long j);
77int NumJour(JMA jma);
78JMA JsmmaatoJMA(int jj, int mm, int aa);
79JMA JApmmaatoJMA(int nj, int mm, int aa);
80
81double HMStoH(HMS hms);
82double HMStoSec(HMS hms);
83
84long DatetoSec(char const* date, char const* heure);
85long DatetoSecOff(char const* date, char const* heure);
86
87HMS HtoHMS(double h);
88HMS DtoDMS(double h);
89HMS DoubletoHMS(double h);
90
91void SetTSolMOff(double tsmoff, char *name);
92void PrtTSolMOff(void);
93int SetTLegOff(char *dtz, char* dhz);
94void PrtTLegInfo(int aa);
95int TLegOffset(JMA date, HMS heure);
96
97HMS TLegtoTU(JMA date, HMS TLeg);
98HMS TUtoTLeg(JMA date, HMS TLeg);
99HMS TUtoTSolM(HMS TU);
100HMS TLegtoTSid(JMA date, HMS TLeg);
101HMS GMST_at_0h_UT(JMA date);
102HMS TUtoTSid(JMA date, HMS TU);
103int TSidtoTU(JMA date, HMS TS, HMS *TU1, HMS *TU2);
104void TSidSetupLaSilla(void);
105
106double ToJulianDay(JMA dateTU, HMS hmsTU);
107int FromJulianDay(double JD,JMA* dateTU, HMS* hmsTU);
108
109double StrgtoDegDec(char *strg);
110char * DegDectoStrg(double deg, char *strg);
111
112double EccEarth(JMA dateTU);
113double ObliqEarth(JMA dateTU);
114double LongEcPerihelie(JMA dateTU);
115void 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
Note: See TracBrowser for help on using the repository browser.