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

Last change on this file since 544 was 544, checked in by rlacroix, 10 years ago

Fix: The conversion of a date to a number of seconds since the time origin was wrong.

Remove the work around in nc4_data_output.cpp which hid this bug.

Also backport this fix in XIOS 1.0.

  • 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            //!< Return the number of seconds since the time origin fixed when creating the calendar
38            operator Time(void) const;
39
40            /// Traitements ///
41            bool checkDate(void); // Vérifie la validité de la date.
42
43            /// Divers accesseurs ///
44            int getYear  (void) const;
45            int getMonth (void) const;
46            int getDay   (void) const;
47            int getHour  (void) const;
48            int getMinute(void) const;
49            int getSecond(void) const;
50
51            //!< Get the calendar associated to the date
52            const CCalendar& getRelCalendar(void) const;
53            bool hasRelCalendar(void) const;
54
55            /// Mutateurs ///
56            void setYear  (int newyear);
57            void setMonth (int newmonth);
58            void setDay   (int newday);
59            void setHour  (int newhour);
60            void setMinute(int newminute);
61            void setSecond(int newsecond);
62
63            void setDate(int yr, int mth, int d,
64                         int hr = 0, int min = 0, int sec = 0);
65
66            void addMonth (int value);
67
68            //!< Set the calendar associated to the date
69            bool setRelCalendar(const CCalendar& relCalendar);
70
71            /// Autres ///
72            StdString toString(void) const;
73            StdString getStryyyymmdd(void) const;
74            string getStr(const string& str) const;
75
76
77         public : /* static */
78
79            static CDate FromString(const StdString & str, const CCalendar & calendar);
80
81         private :
82
83            /// Propriétés privées ///
84            const CCalendar* relCalendar; //!< Calendar associated to the date
85            int year, month, day, hour, minute, second; // Année, mois, ...
86
87
88      }; // class CDate;
89
90} // namespace xios
91
92#endif // __XMLIO_CDate__
Note: See TracBrowser for help on using the repository browser.