1 | #ifndef __XIOS_CDate__ |
---|
2 | #define __XIOS_CDate__ |
---|
3 | |
---|
4 | /// XIOS headers /// |
---|
5 | #include "xios_spl.hpp" |
---|
6 | #include "exception.hpp" |
---|
7 | #include "duration.hpp" |
---|
8 | |
---|
9 | namespace xios |
---|
10 | { |
---|
11 | /// ////////////////////// Déclarations ////////////////////// /// |
---|
12 | class CCalendar; |
---|
13 | |
---|
14 | class CDate |
---|
15 | { |
---|
16 | public : |
---|
17 | |
---|
18 | /// Constructeurs /// |
---|
19 | //!< Create an empty date associated to no calendar |
---|
20 | CDate(void); |
---|
21 | //!< Create an empty date associated to the specified calendar |
---|
22 | CDate(const CCalendar& cal); |
---|
23 | //!< Create a date associated to the specified calendar |
---|
24 | CDate(const CCalendar& cal, int yr, int mth, int d, |
---|
25 | int hr = 0, int min = 0, int sec = 0); |
---|
26 | CDate(const CDate& odate); |
---|
27 | CDate(const CDate* const odate); // Not implemented yet |
---|
28 | |
---|
29 | /// Destructeur /// |
---|
30 | ~CDate(void); |
---|
31 | |
---|
32 | /// Opérateurs /// |
---|
33 | CDate& operator=(const CDate& date); |
---|
34 | bool operator==(const CDate& date); |
---|
35 | friend StdOStream& operator<<(StdOStream& out, const CDate& date); |
---|
36 | friend StdIStream& operator>>(StdIStream& in, CDate& date); |
---|
37 | |
---|
38 | //!< Return the number of seconds since the time origin fixed when creating the calendar |
---|
39 | operator Time(void) const; |
---|
40 | |
---|
41 | /// Traitements /// |
---|
42 | bool checkDate(void); // Vérifie la validité de la date. |
---|
43 | |
---|
44 | /// Divers accesseurs /// |
---|
45 | int getYear (void) const; |
---|
46 | int getMonth (void) const; |
---|
47 | int getDay (void) const; |
---|
48 | int getHour (void) const; |
---|
49 | int getMinute(void) const; |
---|
50 | int getSecond(void) const; |
---|
51 | |
---|
52 | //!< Get the calendar associated to the date |
---|
53 | const CCalendar& getRelCalendar(void) const; |
---|
54 | bool hasRelCalendar(void) const; |
---|
55 | |
---|
56 | //!< Get the number of seconds since the beginning of the year |
---|
57 | int getSecondOfYear() const; |
---|
58 | //!< Get the number of days (expressed as a real number) since the beginning of the year |
---|
59 | double getDayOfYear() const; |
---|
60 | //!< Get the fraction of the current year as a real number between 0 and 1 |
---|
61 | double getFractionOfYear() const; |
---|
62 | //!< Get the number of seconds since the beginning of the day |
---|
63 | int getSecondOfDay() const; |
---|
64 | //!< Get the fraction of the current day as a real number between 0 and 1 |
---|
65 | double getFractionOfDay() const; |
---|
66 | |
---|
67 | /// Mutateurs /// |
---|
68 | void setYear (int newyear); |
---|
69 | void setMonth (int newmonth); |
---|
70 | void setDay (int newday); |
---|
71 | void setHour (int newhour); |
---|
72 | void setMinute(int newminute); |
---|
73 | void setSecond(int newsecond); |
---|
74 | |
---|
75 | void setDate(int yr, int mth, int d, |
---|
76 | int hr = 0, int min = 0, int sec = 0); |
---|
77 | |
---|
78 | void addMonth (int value); |
---|
79 | |
---|
80 | //!< Set the calendar associated to the date |
---|
81 | bool setRelCalendar(const CCalendar& relCalendar); |
---|
82 | |
---|
83 | /// Autres /// |
---|
84 | StdString toString(void) const; |
---|
85 | StdString getStryyyymmdd(void) const; |
---|
86 | string getStr(const string& str) const; |
---|
87 | |
---|
88 | |
---|
89 | public : /* static */ |
---|
90 | |
---|
91 | static CDate FromString(const StdString& str, const CCalendar& calendar); |
---|
92 | |
---|
93 | private : |
---|
94 | |
---|
95 | /// Propriétés privées /// |
---|
96 | const CCalendar* relCalendar; //!< Calendar associated to the date |
---|
97 | int year, month, day, hour, minute, second; // Année, mois, ... |
---|
98 | |
---|
99 | |
---|
100 | }; // class CDate; |
---|
101 | |
---|
102 | } // namespace xios |
---|
103 | |
---|
104 | #endif // __XIOS_CDate__ |
---|