00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_DATE_TIME_H_
00023 #define _FL_DATE_TIME_H_
00024
00025 #include "Fl_Export.h"
00026 #include "Fl_String.h"
00027
00029 class FL_API Fl_Date_Time {
00030 public:
00031 static char dateInputFormat[32];
00032 static char timeInputFormat[32];
00033 static char dateFormat[32];
00034 static char timeFormat[32];
00035 static char datePartsOrder[4];
00036 static char dateSeparator;
00037 static char timeSeparator;
00038 static bool time24Mode;
00039
00040 Fl_Date_Time (short y,short m,short d,short hour=0,short minute=0,short second=0);
00041 Fl_Date_Time (const char * dat);
00042 Fl_Date_Time (const Fl_Date_Time &dt);
00043 Fl_Date_Time (const double dt=0);
00044
00045 static Fl_Date_Time convert (const long);
00046
00047 void format_date(char *str) const;
00048 void format_time(char *str, bool ampm=true) const;
00049
00050
00051
00052 static void Now(Fl_Date_Time dt);
00053 static Fl_Date_Time System();
00054 static Fl_Date_Time Now();
00055 static Fl_Date_Time Date();
00056 static Fl_Date_Time Time();
00057
00058 short days_in_month() const;
00059 short day_of_week() const;
00060 short day_of_year() const;
00061
00062 Fl_String day_name() const;
00063 Fl_String month_name() const;
00064
00065 unsigned date() const;
00066 short day() const;
00067 short month() const;
00068 short year() const;
00069
00070 Fl_String date_string() const;
00071 Fl_String time_string() const;
00072
00073 void decode_date(short *y,short *m,short *d) const;
00074 void decode_time(short *h,short *m,short *s,short *ms) const;
00075
00076 operator double (void) const;
00077
00078 void operator = (const Fl_Date_Time& date);
00079 void operator = (const char * dat);
00080
00081 Fl_Date_Time operator + (int i);
00082 Fl_Date_Time operator - (int i);
00083 Fl_Date_Time operator + (Fl_Date_Time& dt);
00084 Fl_Date_Time operator - (Fl_Date_Time& dt);
00085
00086 Fl_Date_Time& operator += (int i);
00087 Fl_Date_Time& operator -= (int i);
00088 Fl_Date_Time& operator += (Fl_Date_Time& dt);
00089 Fl_Date_Time& operator -= (Fl_Date_Time& dt);
00090
00091 Fl_Date_Time& operator ++ ();
00092 Fl_Date_Time& operator ++ (int);
00093 Fl_Date_Time& operator -- ();
00094 Fl_Date_Time& operator -- (int);
00095
00096 static void decode_date(const double dt,short& y,short& m,short& d);
00097 static void decode_time(const double dt,short& h,short& m,short& s,short& ms);
00098 static void encode_date(double &dt,short y=0,short m=0,short d=0);
00099 static void encode_date(double &dt,const char *dat);
00100 static void encode_time(double &dt,short h=0,short m=0,short s=0,short ms=0);
00101 static void encode_time(double &dt,const char *tim);
00102 static bool is_leap_year(const short year);
00103
00104 protected:
00105 double m_dateTime;
00106 static double dateTimeOffset;
00107
00108 };
00109
00110
00111 static inline bool operator < (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 < (double)dt2 ); }
00112 static inline bool operator <= (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 <= (double)dt2 ); }
00113 static inline bool operator > (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 > (double)dt2 ); }
00114 static inline bool operator >= (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 >= (double)dt2 ); }
00115 static inline bool operator == (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 == (double)dt2 ); }
00116 static inline bool operator != (const Fl_Date_Time &dt1, const Fl_Date_Time &dt2) { return ( (double)dt1 != (double)dt2 ); }
00117
00118 #endif