source: XMLIO_V2/dev/dev_rv/src/XMLIO/calendar.hpp @ 118

Last change on this file since 118 was 118, checked in by hozdoba, 14 years ago

Réorganisation du code gérant le calendrier.

File size: 3.0 KB
Line 
1#ifndef __XMLIO_CALENDAR__
2#define __XMLIO_CALENDAR__
3
4namespace XMLIOSERVER
5{
6   class JulianCalendar : public AbstractCalendar
7   {
8      public :
9         JulianCalendar() : AbstractCalendar("Julian")
10         {/* Ne rien faire de plus */}
11
12         virtual int getYearTotalLength(const Date& d) const
13         { // Retourne la durée d'une année en seconde.
14            if (d.getYear()%4 == 0) return (366 * 86400);
15            return (365 * 86400);
16         }
17
18         virtual int getMonthLength(const Date& d) const
19         { // Retourne la durée du mois en jour.
20            if (d.getMonth() == 2)
21            { if (d.getYear()%4 == 0) return 29; return 28; }
22            return AbstractCalendar::getMonthLength(d);
23         }
24
25         virtual ~JulianCalendar()
26         {/* Ne rien faire de plus */}
27
28   }; // class JulianCalendar
29
30   class GregorianCalendar : public AbstractCalendar
31   {
32      public :
33         GregorianCalendar() : AbstractCalendar("Gregorian")
34         {/* Ne rien faire de plus */}
35
36         virtual int getYearTotalLength(const Date& d) const
37         { // Retourne la durée d'une année en seconde.
38            if ((d.getYear() % 4 == 0) && (d.getYear() % 100 != 0 || d.getYear() % 400 == 0)) return (366 * 86400);
39            return (365 * 86400);
40         }
41
42         virtual int getMonthLength(const Date& d) const
43         { // Retourne la durée du mois en jour.
44            if (d.getMonth() == 2)
45            { // Traitement du cas particulier en Février.
46               if ((d.getYear() % 4 == 0) && (d.getYear() % 100 != 0 || d.getYear() % 400 == 0))
47                  return 29;
48               return 28;
49            }
50            return AbstractCalendar::getMonthLength(d);
51         }
52
53         virtual ~GregorianCalendar()
54         {/* Ne rien faire de plus */}
55
56   }; // class GregorianCalendar
57
58   class NoLeapCalendar : public AbstractCalendar
59   {
60      public :
61         NoLeapCalendar() : AbstractCalendar("NoLeap")
62         {/* Ne rien faire de plus */}
63         virtual ~NoLeapCalendar()
64         {/* Ne rien faire de plus */}
65
66   }; // class NoLeapCalendar
67
68   class AllLeapCalendar : public AbstractCalendar
69   {
70      public :
71         AllLeapCalendar() : AbstractCalendar("AllLeap")
72         {/* Ne rien faire de plus */}
73
74         virtual int getMonthLength(const Date& d) const
75         { if (d.getMonth() == 2) return (29); return AbstractCalendar::getMonthLength(d); }
76
77         virtual int getYearTotalLength(const Date& d) const { return (366 * 86400); }
78
79         virtual ~AllLeapCalendar()
80         {/* Ne rien faire de plus */}
81
82   }; // class NoLeapCalendar
83
84   class D360Calendar : public AbstractCalendar
85   {
86      public :
87         D360Calendar() : AbstractCalendar("D360")
88         {/* Ne rien faire de plus */}
89
90         virtual int getYearTotalLength(const Date& d) const { return (360 * 86400); }
91         virtual int getMonthLength(const Date& d) const { return (30); }
92
93         virtual ~D360Calendar()
94         {/* Ne rien faire de plus */}
95
96   }; // class D360Calendar
97
98} // namespace XMLIOSERVER
99
100#endif // __XMLIO_CALENDAR__
Note: See TracBrowser for help on using the repository browser.