Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

date.h

Go to the documentation of this file.
00001 /*  Inti: Integrated Foundation Classes
00002  *  Copyright (C) 2003 The Inti Development Team.
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00023 
00024 #ifndef INTI_G_DATE_H
00025 #define INTI_G_DATE_H
00026 
00027 #ifndef INTI_OBJECT_H
00028 #include <inti/object.h>
00029 #endif
00030 
00031 #ifndef __G_DATE_H__
00032 #include <glib/gdate.h>
00033 #endif
00034 
00035 namespace Inti {
00036 
00037 namespace G {
00038 
00040 
00041 typedef GTime Time;
00042 
00045 
00046 typedef GDateDay DateDay;
00047 
00051 
00052 typedef GDateYear DateYear;
00053 
00056 
00057 enum DateWeekday
00058 {
00059         DATE_BAD_WEEKDAY = G_DATE_BAD_WEEKDAY, 
00060         DATE_MONDAY = G_DATE_MONDAY, 
00061         DATE_TUESDAY = G_DATE_TUESDAY, 
00062         DATE_WEDNESDAY = G_DATE_WEDNESDAY, 
00063         DATE_THURSDAY = G_DATE_THURSDAY, 
00064         DATE_FRIDAY = G_DATE_FRIDAY, 
00065         DATE_SATURDAY = G_DATE_SATURDAY, 
00066         DATE_SUNDAY = G_DATE_SUNDAY 
00067 };
00068 
00071 
00072 enum DateMonth
00073 {
00074         DATE_BAD_MONTH = G_DATE_BAD_MONTH, 
00075         DATE_JANUARY = G_DATE_JANUARY, 
00076         DATE_FEBRUARY = G_DATE_FEBRUARY, 
00077         DATE_MARCH = G_DATE_MARCH, 
00078         DATE_APRIL = G_DATE_APRIL, 
00079         DATE_MAY = G_DATE_MAY, 
00080         DATE_JUNE = G_DATE_JUNE, 
00081         DATE_JULY = G_DATE_JULY, 
00082         DATE_AUGUST = G_DATE_AUGUST, 
00083         DATE_SEPTEMBER = G_DATE_SEPTEMBER, 
00084         DATE_OCTOBER = G_DATE_OCTOBER, 
00085         DATE_NOVEMBER = G_DATE_NOVEMBER, 
00086         DATE_DECEMBER = G_DATE_DECEMBER 
00087 };
00088 
00124 
00125 class Date : public ReferencedObject
00126 {
00127         GDate *date_;
00128 
00129 public:
00130         static const unsigned int BAD_JULIAN = G_DATE_BAD_JULIAN;
00132 
00133         static const unsigned char BAD_DAY = G_DATE_BAD_DAY;
00135 
00136         static const unsigned short BAD_YEAR = G_DATE_BAD_YEAR;
00138 
00141 
00142         Date();
00145 
00146 
00147         Date(DateDay day, DateMonth month, DateYear year);
00155 
00156         Date(unsigned int julian_day);
00162 
00163         Date(const GDate& date);
00166 
00167 
00168         Date(const Date& src);
00171 
00172         virtual ~Date();
00174 
00175         Date& operator=(const Date& src);
00179 
00183 
00184         GDate* g_date() const { return date_; }
00186 
00187         operator GDate* () const;
00189 
00190         bool valid() const;
00196 
00197         DateWeekday get_weekday() const;
00202 
00203         DateDay get_day() const;
00208 
00209         DateMonth get_month() const;
00214 
00215         DateYear get_year() const;
00220 
00221         unsigned int get_julian() const;
00228 
00229         unsigned int get_day_of_year() const;
00234 
00235         unsigned int get_monday_week_of_year() const;
00241 
00242         unsigned int get_sunday_week_of_year() const;
00249 
00250         bool is_first_of_month() const;
00255 
00256         bool is_last_of_month() const;
00261 
00262         int compare(const Date& other) const;
00269 
00270         bool operator==(const Date& other) const;
00273 
00274         bool operator!=(const Date& other) const;
00277 
00278         bool operator<(const Date& other) const;
00281 
00282         bool operator<=(const Date& other) const;
00285 
00286         bool operator>(const Date& other) const;
00289 
00290         bool operator>=(const Date& other) const;
00293 
00295 
00296         static bool valid_day(DateDay day);
00302 
00303         static bool valid_month(DateMonth month);
00309 
00310         static bool valid_year(DateYear year);
00317 
00318         static bool valid_weekday(DateWeekday weekday);
00324 
00325         static bool valid_julian(unsigned int julian_date);
00332 
00333         static bool valid_dmy(DateDay day, DateMonth month, DateYear year);
00341 
00342         static bool is_leap_year(DateYear year);
00346 
00347         static unsigned char get_days_in_month(DateMonth month, DateYear year);
00352 
00353         static unsigned char get_monday_weeks_in_year(DateYear year);
00362 
00363         static unsigned char get_sunday_weeks_in_year(DateYear year);
00372 
00375 
00376         void clear();
00379 
00380         void set_parse(const String& str);
00392 
00393         void set_time(Time time);
00401 
00402         void set_day(DateDay day);
00407 
00408         void set_month(DateMonth month);
00413 
00414         void set_year(DateYear year);
00419 
00420         void set_dmy(DateDay day, DateMonth month, DateYear year);
00428 
00429         void set_julian(unsigned int julian_date);
00432 
00433         void add_days(unsigned int n_days);
00438 
00439         void subtract_days(unsigned int n_days);
00444 
00445         void add_months(unsigned int n_months);
00452 
00453         void subtract_months(unsigned int n_months);
00459 
00460         void add_years(unsigned int n_years);
00466 
00467         void subtract_years(unsigned int n_years);
00474 
00475         int days_between(const Date& date1, const Date& date2);
00482 
00483         void to_struct_tm(struct tm *tm);
00488 
00489         void clamp(const Date *min_date, const Date *max_date);
00496 
00497         void order(Date& other);
00501 
00502         String format(const String& date_format);
00509 
00511 };
00512 
00513 } // namespace G
00514 
00515 } // namespace Inti
00516 
00517 #endif // INTI_G_DATE_H
00518 
Main Page - Footer


Generated on Sun Sep 14 20:08:02 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002