|
Xbase Class Library 2.0.0
|
00001 /* $Id: xdate.h,v 1.7 2000/11/10 19:04:17 dbryson Exp $ 00002 00003 Xbase project source code 00004 00005 This file contains a header file for the xbDate object, which is 00006 used for handling dates. 00007 00008 Copyright (C) 1997 StarTech, Gary A. Kunkel 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 00024 Contact: 00025 00026 Mail: 00027 00028 Technology Associates, Inc. 00029 XBase Project 00030 1455 Deming Way #11 00031 Sparks, NV 89434 00032 USA 00033 00034 Email: 00035 00036 xbase@techass.com 00037 00038 See our website at: 00039 00040 xdb.sourceforge.net 00041 00042 00043 V 1.0 10/10/97 - Initial release of software 00044 V 1.5 1/2/98 - Added memo field support 00045 V 1.6a 4/1/98 - Added expression support 00046 V 1.6b 4/8/98 - Numeric index keys 00047 V 1.7.1 5/25/98 - Enhancements/bug fixes from eljorgo@fontun.com 00048 V 1.8.0a 1/29/99 - Added Default Date Format processing 00049 V 1.9.0 6/23/99 - CPP ified and minor bug fixes 00050 */ 00051 00055 #ifndef __XB_XDATE_H__ 00056 #define __XB_XDATE_H__ 00057 00058 #ifdef __GNUG__ 00059 #pragma interface 00060 #endif 00061 00062 #ifdef __WIN32__ 00063 #include <xbase/xbconfigw32.h> 00064 #else 00065 #include <xbase/xbconfig.h> 00066 #endif 00067 00068 #include <xbase/xbstring.h> 00069 00070 #define XB_FMT_WEEK 1 00071 #define XB_FMT_MONTH 2 00072 #define XB_FMT_YEAR 3 00073 00075 00078 class XBDLLEXPORT xbDate { 00079 public: 00080 xbDate(); 00081 xbDate( const char * Date8 ); 00082 xbDate( const xbString &Date8 ); 00083 00085 00087 const xbString & GetDate() const 00088 { return cDate8; }; 00090 00092 xbString & GetDate() 00093 { return cDate8; }; 00095 00097 const xbString & GetFormattedDate() const 00098 { return fDate; }; 00100 00102 xbString & GetFormattedDate() 00103 { return fDate; }; 00104 00105 int SetDate( const char * Date8 ); 00107 00109 int SetDate( const xbString & Date8 ) 00110 { return SetDate((const char *) Date8 ); }; 00111 00112 long JulianDays ( const char *Date8 ) const; 00114 00116 long JulianDays ( const xbString & Date8 ) const 00117 { return JulianDays((const char *) Date8 ); }; 00119 00121 long JulianDays () const 00122 { return JulianDays((const char *) cDate8 ); }; 00123 00124 int YearOf ( const char *Date8 ) const; 00126 00128 int YearOf ( const xbString & Date8 ) const 00129 { return YearOf((const char *) Date8 ); }; 00131 00133 int YearOf () const 00134 { return YearOf((const char *) cDate8 ); }; 00135 00136 int MonthOf ( const char *Date8 ) const; 00138 00140 int MonthOf ( const xbString &Date8 ) const 00141 { return MonthOf((const char *) Date8 ); }; 00143 00145 int MonthOf () const 00146 { return MonthOf(( const char *) cDate8 ); }; 00147 00148 int DayOf ( int Format, const char *Date8 ) const; 00150 00152 int DayOf ( int Format, const xbString &Date8 ) const 00153 { return DayOf( Format, (const char *) Date8 ); }; 00155 00157 int DayOf ( int Format ) const 00158 { return DayOf( Format, (const char *) cDate8 ); }; 00159 00160 int IsLeapYear ( const char *Date8 ) const; 00162 00164 int IsLeapYear ( const xbString &Date8 ) const 00165 { return IsLeapYear((const char *) Date8 ); }; 00167 00169 int IsLeapYear () const 00170 { return IsLeapYear((const char *) cDate8 ); }; 00171 00172 int DateIsValid ( const char *Date8 ) const; 00174 00176 int DateIsValid ( const xbString & Date8 ) const 00177 { return DateIsValid( (const char *) Date8 ); }; 00178 00179 xbString& LastDayOfMonth( const char *Date8 ); 00181 00183 xbString& LastDayOfMonth( const xbString & Date8 ) 00184 { return LastDayOfMonth((const char *) Date8 ); }; 00186 00188 xbString& LastDayOfMonth() 00189 { return LastDayOfMonth((const char *) cDate8 ); }; 00190 00191 xbString& Sysdate (); 00192 xbString& JulToDate8( long ); 00193 00194 xbString& FormatDate( const char *Format, const char *Date8 ); 00196 00198 xbString& FormatDate( const xbString &Format, const char *Date8 ) 00199 { return FormatDate((const char *) Format, Date8 ); }; 00201 00203 xbString& FormatDate( const char *Format, const xbString &Date8 ) 00204 { return FormatDate( Format, (const char *) Date8 ); }; 00206 00208 xbString& FormatDate( const xbString &Format, const xbString &Date8 ) 00209 { return FormatDate((const char *) Format,(const char *) Date8 ); }; 00211 00213 xbString& FormatDate( const char *Format ) 00214 { return FormatDate( (const char *) Format, (const char *) cDate8 ); }; 00216 00218 xbString& FormatDate( const xbString &Format ) 00219 { return FormatDate((const char *) Format, (const char *) cDate8 ); }; 00220 00221 xbString& CharDayOf ( const char *Date8 ); 00223 00225 xbString& CharDayOf ( const xbString &Date8 ) 00226 { return CharDayOf((const char *) Date8 ); }; 00228 00230 xbString& CharDayOf () 00231 { return CharDayOf((const char *) cDate8 ); }; 00232 00233 xbString& CharMonthOf ( const char *Date8 ); 00235 00237 xbString& CharMonthOf ( const xbString &Date8 ) 00238 { return CharMonthOf(( const char *) Date8 ); }; 00240 00242 xbString& CharMonthOf () 00243 { return CharMonthOf(( const char *) cDate8 ); }; 00244 00245 xbString &operator+=( int ); 00246 xbString &operator-=( int ); 00247 xbString &operator++( int ); /* post increment */ 00248 xbString &operator--( int ); /* post increment */ 00249 xbString &operator+ ( int ); 00250 xbString &operator- ( int ); 00251 long operator-( const xbDate & ) const; 00252 int operator==( const xbDate & ) const; 00253 int operator!=( const xbDate & ) const; 00254 int operator< ( const xbDate & ) const; 00255 int operator> ( const xbDate & ) const; 00256 int operator<=( const xbDate & ) const; 00257 int operator>=( const xbDate & ) const; 00258 00259 protected: 00260 void SetDateTables(); 00261 xbString cDate8; /* CCYYMMDD date format */ 00262 xbString fDate; /* other date format */ 00263 static int AggregatedDaysInMonths[2][13]; 00264 static int DaysInMonths[2][13]; 00265 static const xbString *Days[7]; 00266 static const xbString *Months[12]; 00267 }; 00268 00269 #endif // __XB_XDATE_H__ 00270
1.7.3