Xbase64 Class Library  3.1.2
xbdate.h
Go to the documentation of this file.
1 /* xbdate.h
2 
3  Xbase64 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,2003 Gary A Kunkel
9 
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program 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
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 
24 
25  Contact:
26 
27  Email:
28 
29  xdb-devel@lists.sourceforge.net
30  xdb-users@lists.sourceforge.net
31 
32 
33  Regular Mail:
34 
35  XBase Support
36  149C South Main St
37  Keller Texas, 76248
38  USA
39 
40 */
41 
45 #ifndef __XB_XBDATE_H__
46 #define __XB_XBDATE_H__
47 
48 #ifdef __GNU_LesserG__
49 #pragma interface
50 #endif
51 
52 #ifdef __WIN32__
53 #include <xbase64/xbwincfg.h>
54 #else
55 #include <xbase64/xbconfig.h>
56 #endif
57 
58 #include <xbase64/xbstring.h>
59 
60 #define XB_FMT_WEEK 1
61 #define XB_FMT_MONTH 2
62 #define XB_FMT_YEAR 3
63 
65 
69  public:
70  xbDate();
71  xbDate( const char * Date8 );
72  xbDate( const xbString &Date8 );
73  virtual ~xbDate();
74 
76 
78  const xbString & GetDate() const
79  { return cDate8; };
81 
83  xbString & GetDate()
84  { return cDate8; };
86 
88  const xbString & GetFormattedDate() const
89  { return fDate; };
91 
93  xbString & GetFormattedDate()
94  { return fDate; };
95 
96  int SetDate( const char * Date8 );
98 
100  int SetDate( const xbString & Date8 )
101  { return SetDate((const char *) Date8 ); };
102 
103  long JulianDays ( const char *Date8 ) const;
105 
107  long JulianDays ( const xbString & Date8 ) const
108  { return JulianDays((const char *) Date8 ); };
110 
112  long JulianDays () const
113  { return JulianDays((const char *) cDate8 ); };
114 
115  int YearOf ( const char *Date8 ) const;
117 
119  int YearOf ( const xbString & Date8 ) const
120  { return YearOf((const char *) Date8 ); };
122 
124  int YearOf () const
125  { return YearOf((const char *) cDate8 ); };
126 
128 
130  int CenturyOf ( const char *Date8 ) const;
131 
132  int MonthOf ( const char *Date8 ) const;
134 
136  int MonthOf ( const xbString &Date8 ) const
137  { return MonthOf((const char *) Date8 ); };
139 
141  int MonthOf () const
142  { return MonthOf(( const char *) cDate8 ); };
143 
144  int DayOf ( int Format, const char *Date8 ) const;
146 
148  int DayOf ( int Format, const xbString &Date8 ) const
149  { return DayOf( Format, (const char *) Date8 ); };
151 
153  int DayOf ( int Format ) const
154  { return DayOf( Format, (const char *) cDate8 ); };
155 
156  int IsLeapYear ( const char *Date8 ) const;
158 
160  int IsLeapYear ( const xbString &Date8 ) const
161  { return IsLeapYear((const char *) Date8 ); };
163 
165  int IsLeapYear () const
166  { return IsLeapYear((const char *) cDate8 ); };
167 
169 
171  int CalcRollingCenturyForYear( int ) const;
172 
173 
174  int DateIsValid ( const char *Date8 ) const;
176 
178  int DateIsValid ( const xbString & Date8 ) const
179  { return DateIsValid( (const char *) Date8 ); };
180 
181  xbString& LastDayOfMonth( const char *Date8 );
183 
185  xbString& LastDayOfMonth( const xbString & Date8 )
186  { return LastDayOfMonth((const char *) Date8 ); };
188 
190  xbString& LastDayOfMonth()
191  { return LastDayOfMonth((const char *) cDate8 ); };
192 
193  xbString& Sysdate ();
194  xbString& JulToDate8( long );
195 
197 
199  xbString& FormatCTODdate( const char * indate );
200 
202 
204  xbString& FormatDate( const char *Format, const char *Date8 );
206 
208  xbString& FormatDate( const xbString &Format, const char *Date8 )
209  { return FormatDate((const char *) Format, Date8 ); };
211 
213  xbString& FormatDate( const char *Format, const xbString &Date8 )
214  { return FormatDate( Format, (const char *) Date8 ); };
216 
218  xbString& FormatDate( const xbString &Format, const xbString &Date8 )
219  { return FormatDate((const char *) Format,(const char *) Date8 ); };
221 
223  xbString& FormatDate( const char *Format )
224  { return FormatDate( (const char *) Format, (const char *) cDate8 ); };
226 
228  xbString& FormatDate( const xbString &Format )
229  { return FormatDate((const char *) Format, (const char *) cDate8 ); };
230 
231  xbString& CharDayOf ( const char *Date8 );
233 
235  xbString& CharDayOf ( const xbString &Date8 )
236  { return CharDayOf((const char *) Date8 ); };
238 
240  xbString& CharDayOf ()
241  { return CharDayOf((const char *) cDate8 ); };
242 
243  xbString& CharMonthOf ( const char *Date8 );
245 
247  xbString& CharMonthOf ( const xbString &Date8 )
248  { return CharMonthOf(( const char *) Date8 ); };
250 
252  xbString& CharMonthOf ()
253  { return CharMonthOf(( const char *) cDate8 ); };
254 
255  xbString &operator+=( int );
256  xbString &operator-=( int );
257  xbString &operator++( int ); /* post increment */
258  xbString &operator--( int ); /* post increment */
259  xbString &operator+ ( int );
260  xbString &operator- ( int );
261  long operator-( const xbDate & ) const;
262  int operator==( const xbDate & ) const;
263  int operator!=( const xbDate & ) const;
264  int operator< ( const xbDate & ) const;
265  int operator> ( const xbDate & ) const;
266  int operator<=( const xbDate & ) const;
267  int operator>=( const xbDate & ) const;
268 
269  protected:
270  void SetDateTables();
271  xbString cDate8; /* CCYYMMDD date format */
272  xbString fDate; /* other date format */
273  static int AggregatedDaysInMonths[2][13];
274  static int DaysInMonths[2][13];
275 };
276 
277 #endif // __XB_XBDATE_H__
278