source: XIOS/dev/branch_yushan_merged/src/date.hpp @ 1205

Last change on this file since 1205 was 1105, checked in by mhnguyen, 7 years ago

Adding comparison operator between objects of XIOS.
Two objects of a same type are considered equal if they have same non-empty
attributes which have same values

+) Add operator== to class CArray
+) Add comparison operator to some basic attribute classes
+) Add operator== to date and duration (It seems that they don't serve much)

Test
+) On Curie
+) No Unit tests but test with transformation work (the next commit)

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 3.6 KB
Line 
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
9namespace 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__
Note: See TracBrowser for help on using the repository browser.