source: XIOS/trunk/src/date.hpp @ 1501

Last change on this file since 1501 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
RevLine 
[591]1#ifndef __XIOS_CDate__
2#define __XIOS_CDate__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "exception.hpp"
7#include "duration.hpp"
8
[335]9namespace xios
[219]10{
11      /// ////////////////////// Déclarations ////////////////////// ///
12      class CCalendar;
13
14      class CDate
15      {
16         public :
17
18            /// Constructeurs ///
[532]19            //!< Create an empty date associated to no calendar
20            CDate(void);
21            //!< Create an empty date associated to the specified calendar
[549]22            CDate(const CCalendar& cal);
[532]23            //!< Create a date associated to the specified calendar
[549]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
[219]28
29            /// Destructeur ///
30            ~CDate(void);
31
32            /// Opérateurs ///
[549]33            CDate& operator=(const CDate& date);
[1105]34            bool operator==(const CDate& date);
[549]35            friend StdOStream& operator<<(StdOStream& out, const CDate& date);
[550]36            friend StdIStream& operator>>(StdIStream& in, CDate& date);
[219]37
[544]38            //!< Return the number of seconds since the time origin fixed when creating the calendar
39            operator Time(void) const;
[219]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
[532]52            //!< Get the calendar associated to the date
53            const CCalendar& getRelCalendar(void) const;
54            bool hasRelCalendar(void) const;
[219]55
[549]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
[219]67            /// Mutateurs ///
68            void setYear  (int newyear);
69            void setMonth (int newmonth);
[532]70            void setDay   (int newday);
71            void setHour  (int newhour);
72            void setMinute(int newminute);
73            void setSecond(int newsecond);
[219]74
[532]75            void setDate(int yr, int mth, int d,
76                         int hr = 0, int min = 0, int sec = 0);
77
[219]78            void addMonth (int value);
79
[532]80            //!< Set the calendar associated to the date
81            bool setRelCalendar(const CCalendar& relCalendar);
82
[219]83            /// Autres ///
84            StdString toString(void) const;
[321]85            StdString getStryyyymmdd(void) const;
[431]86            string getStr(const string& str) const;
[219]87
[431]88
[219]89         public : /* static */
90
[549]91            static CDate FromString(const StdString& str, const CCalendar& calendar);
[219]92
93         private :
94
95            /// Propriétés privées ///
[532]96            const CCalendar* relCalendar; //!< Calendar associated to the date
[219]97            int year, month, day, hour, minute, second; // Année, mois, ...
98
99
100      }; // class CDate;
101
[335]102} // namespace xios
[219]103
[591]104#endif // __XIOS_CDate__
Note: See TracBrowser for help on using the repository browser.