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

Last change on this file since 532 was 532, checked in by rlacroix, 9 years ago

Add a new attribute type for dates and use it for the context's start_date and time_origin.

The "xios_date" type should now be used to get/set date attributes through the Fortran interface. This avoids using strings to manipulate dates.

  • 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: 2.9 KB
Line 
1#ifndef __XMLIO_CDate__
2#define __XMLIO_CDate__
3
4/// xios headers ///
5#include "xmlioserver_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            friend StdOStream & operator<<(StdOStream & out, const CDate & date);
35            friend StdIStream & operator>>(StdIStream & in, CDate & date); // Non testée.
36
37            operator Time(void) const;  // Retourne le nombre de secondes écoulées depuis la date d'origine définie dans le calendrier.
38
39            /// Traitements ///
40            bool checkDate(void); // Vérifie la validité de la date.
41
42            /// Divers accesseurs ///
43            int getYear  (void) const;
44            int getMonth (void) const;
45            int getDay   (void) const;
46            int getHour  (void) const;
47            int getMinute(void) const;
48            int getSecond(void) const;
49
50            //!< Get the calendar associated to the date
51            const CCalendar& getRelCalendar(void) const;
52            bool hasRelCalendar(void) const;
53
54            /// Mutateurs ///
55            void setYear  (int newyear);
56            void setMonth (int newmonth);
57            void setDay   (int newday);
58            void setHour  (int newhour);
59            void setMinute(int newminute);
60            void setSecond(int newsecond);
61
62            void setDate(int yr, int mth, int d,
63                         int hr = 0, int min = 0, int sec = 0);
64
65            void addMonth (int value);
66
67            //!< Set the calendar associated to the date
68            bool setRelCalendar(const CCalendar& relCalendar);
69
70            /// Autres ///
71            StdString toString(void) const;
72            StdString getStryyyymmdd(void) const;
73            string getStr(const string& str) const;
74
75
76         public : /* static */
77
78            static CDate FromString(const StdString & str, const CCalendar & calendar);
79
80         private :
81
82            /// Propriétés privées ///
83            const CCalendar* relCalendar; //!< Calendar associated to the date
84            int year, month, day, hour, minute, second; // Année, mois, ...
85
86
87      }; // class CDate;
88
89} // namespace xios
90
91#endif // __XMLIO_CDate__
Note: See TracBrowser for help on using the repository browser.