00001
00002 #ifndef d_Date_h
00003 #define d_Date_h 1
00004
00005 #include "oTime.h"
00006
00007 class _ODLL d_Timestamp;
00008 class _ODLL d_Interval;
00009
00010
00011
00012
00013
00014 class _ODLL d_Date : private oTime
00015 {
00016 public:
00017 enum Weekday { Sunday=0, Monday=1, Tuesday=2, Wednesday=3, Thursday=4, Friday=5, Saturday=6};
00018 enum Month { January=1, February=2, March=3, April=4, May=5, June=6, July=7, August=8, September=9,October=10, November=11, December=12};
00019
00020 d_Date( void );
00021 d_Date(long julian_day);
00022 d_Date(unsigned short year, unsigned short month=1, unsigned short day=1);
00023 d_Date(const d_Date&);
00024 d_Date(const d_Timestamp&);
00025 d_Date& operator=(const d_Date&);
00026 d_Date& operator=(const d_Timestamp&);
00027
00028 void setDate(unsigned short year, unsigned short month, unsigned short day);
00029
00030 unsigned short year() const;
00031 unsigned short month() const;
00032 unsigned short day() const;
00033 unsigned short day_of_year() const;
00034 Weekday day_of_week() const;
00035
00036 static d_Date current();
00037 d_Date& next(Weekday);
00038 d_Date& previous(Weekday);
00039
00040 d_Date& operator+=(const d_Interval&);
00041 d_Date& operator+=(int ndays);
00042 d_Date& operator++();
00043 d_Date operator++(int);
00044 d_Date& operator-=(const d_Interval&);
00045 d_Date& operator-=(int ndays);
00046 d_Date& operator--();
00047 d_Date operator--(int);
00048 d_Interval operator-(const d_Date&);
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 int is_leap_year() const;
00066 static int is_leap_year(unsigned short year);
00067 int is_between(const d_Date&, const d_Date&) const;
00068 static int days_in_year(unsigned short);
00069 int days_in_year() const;
00070 static int days_in_month(unsigned short, unsigned short);
00071 int days_in_month() const;
00072 static int is_valid_date(unsigned short, unsigned short, unsigned short);
00073
00074 private:
00075 void setCurrent( void );
00076
00077 static d_Date* staticDate;
00078 };
00079
00080
00081
00082 #endif