Xbase Class Library  2.0.0
xdate.h
Go to the documentation of this file.
1 /* $Id: xdate.h,v 1.7 2000/11/10 19:04:17 dbryson Exp $
2 
3  Xbase project source code
4 
5  This file contains a header file for the xbDate object, which is
6  used for handling dates.
7 
8  Copyright (C) 1997 StarTech, Gary A. Kunkel
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24  Contact:
25 
26  Mail:
27 
28  Technology Associates, Inc.
29  XBase Project
30  1455 Deming Way #11
31  Sparks, NV 89434
32  USA
33 
34  Email:
35 
36  xbase@techass.com
37 
38  See our website at:
39 
40  xdb.sourceforge.net
41 
42 
43  V 1.0 10/10/97 - Initial release of software
44  V 1.5 1/2/98 - Added memo field support
45  V 1.6a 4/1/98 - Added expression support
46  V 1.6b 4/8/98 - Numeric index keys
47  V 1.7.1 5/25/98 - Enhancements/bug fixes from eljorgo@fontun.com
48  V 1.8.0a 1/29/99 - Added Default Date Format processing
49  V 1.9.0 6/23/99 - CPP ified and minor bug fixes
50 */
51 
55 #ifndef __XB_XDATE_H__
56 #define __XB_XDATE_H__
57 
58 #ifdef __GNUG__
59 #pragma interface
60 #endif
61 
62 #ifdef __WIN32__
63 #include <xbase/xbconfigw32.h>
64 #else
65 #include <xbase/xbconfig.h>
66 #endif
67 
68 #include <xbase/xbstring.h>
69 
70 #define XB_FMT_WEEK 1
71 #define XB_FMT_MONTH 2
72 #define XB_FMT_YEAR 3
73 
75 
79  public:
80  xbDate();
81  xbDate( const char * Date8 );
82  xbDate( const xbString &Date8 );
83 
85 
87  const xbString & GetDate() const
88  { return cDate8; };
90 
93  { return cDate8; };
95 
97  const xbString & GetFormattedDate() const
98  { return fDate; };
100 
103  { return fDate; };
104 
105  int SetDate( const char * Date8 );
107 
109  int SetDate( const xbString & Date8 )
110  { return SetDate((const char *) Date8 ); };
111 
112  long JulianDays ( const char *Date8 ) const;
114 
116  long JulianDays ( const xbString & Date8 ) const
117  { return JulianDays((const char *) Date8 ); };
119 
121  long JulianDays () const
122  { return JulianDays((const char *) cDate8 ); };
123 
124  int YearOf ( const char *Date8 ) const;
126 
128  int YearOf ( const xbString & Date8 ) const
129  { return YearOf((const char *) Date8 ); };
131 
133  int YearOf () const
134  { return YearOf((const char *) cDate8 ); };
135 
136  int MonthOf ( const char *Date8 ) const;
138 
140  int MonthOf ( const xbString &Date8 ) const
141  { return MonthOf((const char *) Date8 ); };
143 
145  int MonthOf () const
146  { return MonthOf(( const char *) cDate8 ); };
147 
148  int DayOf ( int Format, const char *Date8 ) const;
150 
152  int DayOf ( int Format, const xbString &Date8 ) const
153  { return DayOf( Format, (const char *) Date8 ); };
155 
157  int DayOf ( int Format ) const
158  { return DayOf( Format, (const char *) cDate8 ); };
159 
160  int IsLeapYear ( const char *Date8 ) const;
162 
164  int IsLeapYear ( const xbString &Date8 ) const
165  { return IsLeapYear((const char *) Date8 ); };
167 
169  int IsLeapYear () const
170  { return IsLeapYear((const char *) cDate8 ); };
171 
172  int DateIsValid ( const char *Date8 ) const;
174 
176  int DateIsValid ( const xbString & Date8 ) const
177  { return DateIsValid( (const char *) Date8 ); };
178 
179  xbString& LastDayOfMonth( const char *Date8 );
181 
183  xbString& LastDayOfMonth( const xbString & Date8 )
184  { return LastDayOfMonth((const char *) Date8 ); };
186 
189  { return LastDayOfMonth((const char *) cDate8 ); };
190 
191  xbString& Sysdate ();
192  xbString& JulToDate8( long );
193 
194  xbString& FormatDate( const char *Format, const char *Date8 );
196 
198  xbString& FormatDate( const xbString &Format, const char *Date8 )
199  { return FormatDate((const char *) Format, Date8 ); };
201 
203  xbString& FormatDate( const char *Format, const xbString &Date8 )
204  { return FormatDate( Format, (const char *) Date8 ); };
206 
208  xbString& FormatDate( const xbString &Format, const xbString &Date8 )
209  { return FormatDate((const char *) Format,(const char *) Date8 ); };
211 
213  xbString& FormatDate( const char *Format )
214  { return FormatDate( (const char *) Format, (const char *) cDate8 ); };
216 
218  xbString& FormatDate( const xbString &Format )
219  { return FormatDate((const char *) Format, (const char *) cDate8 ); };
220 
221  xbString& CharDayOf ( const char *Date8 );
223 
225  xbString& CharDayOf ( const xbString &Date8 )
226  { return CharDayOf((const char *) Date8 ); };
228 
231  { return CharDayOf((const char *) cDate8 ); };
232 
233  xbString& CharMonthOf ( const char *Date8 );
235 
237  xbString& CharMonthOf ( const xbString &Date8 )
238  { return CharMonthOf(( const char *) Date8 ); };
240 
243  { return CharMonthOf(( const char *) cDate8 ); };
244 
245  xbString &operator+=( int );
246  xbString &operator-=( int );
247  xbString &operator++( int ); /* post increment */
248  xbString &operator--( int ); /* post increment */
249  xbString &operator+ ( int );
250  xbString &operator- ( int );
251  long operator-( const xbDate & ) const;
252  int operator==( const xbDate & ) const;
253  int operator!=( const xbDate & ) const;
254  int operator< ( const xbDate & ) const;
255  int operator> ( const xbDate & ) const;
256  int operator<=( const xbDate & ) const;
257  int operator>=( const xbDate & ) const;
258 
259  protected:
260  void SetDateTables();
261  xbString cDate8; /* CCYYMMDD date format */
262  xbString fDate; /* other date format */
263  static int AggregatedDaysInMonths[2][13];
264  static int DaysInMonths[2][13];
265  static const xbString *Days[7];
266  static const xbString *Months[12];
267 };
268 
269 #endif // __XB_XDATE_H__
270 
const xbString & GetFormattedDate() const
Short description.
Definition: xdate.h:97
xbString & GetFormattedDate()
Short description.
Definition: xdate.h:102
int IsLeapYear() const
Short description.
Definition: xdate.h:169
xbString fDate
Definition: xdate.h:262
int IsLeapYear(const xbString &Date8) const
Short description.
Definition: xdate.h:164
int YearOf(const xbString &Date8) const
Short description.
Definition: xdate.h:128
xbString operator-(const xbString &s1, const xbString &s2)
Short description.
Definition: xbstring.cpp:592
xbString & CharDayOf()
Short description.
Definition: xdate.h:230
xbDate class
Definition: xdate.h:78
xbString & FormatDate(const xbString &Format)
Short description.
Definition: xdate.h:218
#define XBDLLEXPORT
Definition: xbase.h:101
xbString & LastDayOfMonth()
Short description.
Definition: xdate.h:188
int MonthOf() const
Short description.
Definition: xdate.h:145
xbString operator+(const xbString &s1, const xbString &s2)
Short description.
Definition: xbstring.cpp:601
xbString & FormatDate(const xbString &Format, const char *Date8)
Short description.
Definition: xdate.h:198
xbString & LastDayOfMonth(const xbString &Date8)
Short description.
Definition: xdate.h:183
long JulianDays(const xbString &Date8) const
Short description.
Definition: xdate.h:116
xbString class
Definition: xbstring.h:69
xbString & FormatDate(const xbString &Format, const xbString &Date8)
Short description.
Definition: xdate.h:208
int DayOf(int Format) const
Short description.
Definition: xdate.h:157
int DateIsValid(const xbString &Date8) const
Short description.
Definition: xdate.h:176
xbString cDate8
Definition: xdate.h:261
xbString & CharMonthOf(const xbString &Date8)
Short description.
Definition: xdate.h:237
int SetDate(const xbString &Date8)
Short description.
Definition: xdate.h:109
xbString & CharDayOf(const xbString &Date8)
Short description.
Definition: xdate.h:225
xbString & FormatDate(const char *Format, const xbString &Date8)
Short description.
Definition: xdate.h:203
xbString & CharMonthOf()
Short description.
Definition: xdate.h:242
xbString & GetDate()
Short description.
Definition: xdate.h:92
xbString & FormatDate(const char *Format)
Short description.
Definition: xdate.h:213
int MonthOf(const xbString &Date8) const
Short description.
Definition: xdate.h:140
int DayOf(int Format, const xbString &Date8) const
Short description.
Definition: xdate.h:152
bool operator!=(const xbString &s1, const char *s2)
Short description.
Definition: xbstring.cpp:488
bool operator==(const xbString &s1, const char *s2)
Short description.
Definition: xbstring.cpp:469
int YearOf() const
Short description.
Definition: xdate.h:133
const xbString & GetDate() const
Short description.
Definition: xdate.h:87
long JulianDays() const
Short description.
Definition: xdate.h:121