source: XIOS/dev/dev_trunk_omp/src/date.hpp @ 1628

Last change on this file since 1628 was 1628, checked in by yushan, 5 years ago

bug fix (Nb of files less than Nb of servers)

  • 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.7 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);
[1158]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 ///
[1628]45            inline int getYear  (void) const {return year;};
46            inline int getMonth (void) const {return month;};
47            inline int getDay   (void) const {return day;};
48            inline int getHour  (void) const {return hour;};
49            inline int getMinute(void) const {return minute;};
50            inline int getSecond(void) const {return second;};
[219]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.