Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
xbdate.h
Go to the documentation of this file.
1/* xbdate.h
2
3XBase64 Software Library
4
5Copyright (c) 1997,2003,2014,2022 Gary A Kunkel
6
7The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
8
9Email Contact:
10
11 XDB-devel@lists.sourceforge.net
12 XDB-users@lists.sourceforge.net
13
14*/
15
16
17#ifndef __XB_XBDATE_H__
18#define __XB_XBDATE_H__
19
20#ifdef CMAKE_COMPILER_IS_GNUCC
21#pragma interface
22#endif
23
24
25namespace xb{
26
27#define XB_FMT_WEEK 1
28#define XB_FMT_MONTH 2
29#define XB_FMT_YEAR 3
30
31// next value is added to the date calculation to match dbase calculation
32// first valid dbase date is 01/01/0001
33#define JUL_OFFSET 1721425L
34
35
37
62class XBDLLEXPORT xbDate : public xbSsv {
63 public:
64
65 xbDate();
66 xbDate( const char * Date8 );
67 xbDate( const xbString &Date8 );
68 xbDate( xbInt32 lJulDate );
69 xbDate( xbUInt16 iInit ); // Constructor used to set the static variables, also defaults to sysdate
70 ~xbDate();
71
72 void operator=( const xbDate &d );
73 void operator+=( xbInt32 i );
74 void operator-=( xbInt32 i );
75 void operator++( xbInt32 i );
76 void operator--( xbInt32 i );
77
78 xbInt32 operator-( const xbDate & ) const;
79 const char * operator-( xbInt32 i );
80 const char * operator+( xbInt32 i );
81
82 xbBool operator==( const xbDate & ) const;
83 xbBool operator!=( const xbDate & ) const;
84 xbBool operator< ( const xbDate & ) const;
85 xbBool operator> ( const xbDate & ) const;
86 xbBool operator<=( const xbDate & ) const;
87 xbBool operator>=( const xbDate & ) const;
88
89 xbInt16 CalcRollingCenturyForYear( xbInt16 year ) const;
90 xbInt16 CenturyOf() const;
91 xbInt16 CharDayOf( xbString &sOutCharDay );
92 xbInt16 CharMonthOf( xbString &sOutCharMonth );
93 xbBool DateIsValid ( const xbString &sDate8 ) const;
94 xbInt16 DayOf( xbInt16 iFormat ) const;
95 xbInt16 CTOD( const xbString &sCtodInDate );
96 xbInt16 FormatDate( const xbString &sFmtIn, xbString &sFmtOut );
97 const char *Str() const;
98 xbBool IsLeapYear( xbInt16 iYear ) const;
99 xbBool IsLeapYear() const;
100 xbBool IsNull() const;
101 xbInt32 JulianDays() const;
102 xbInt16 JulToDate8( xbInt32 lJulDate );
103 xbInt16 LastDayOfMonth();
104 xbInt16 MonthOf() const;
105 xbInt16 Set( const xbString &Date8 );
106 xbInt16 Sysdate();
107 xbInt16 YearOf() const;
108
109#ifdef XB_DEBUG_SUPPORT
110 void Dump( const char * title );
111 void DumpDateTables();
112#endif
113
114 private:
115 void SetDateTables();
116 xbString sDate8; // CCYYMMDD date format ie; 20140718
117 // Null date is identified by sDate.Len() < 8
118
119 static int iAggregatedDaysInMonths[2][13];
120 static int iDaysInMonths[2][13];
121};
122
123} /* namespace */
124#endif /*__XB_XBDATE_H__ */
125
xbDate class.
Definition: xbdate.h:62
Class for handling shared system variables.
Definition: xbssv.h:59
Class for handling string data.
Definition: xbstring.h:50
Definition: xbdate.cpp:19
short int xbBool
Definition: xbtypes.h:24