Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
|
#include <xbdate.h>
Public Member Functions | |
xbDate () | |
Constructor. More... | |
xbDate (const char *Date8) | |
Constructor. More... | |
xbDate (const xbString &Date8) | |
Constructor. More... | |
xbDate (xbInt32 lJulDate) | |
Constructor. More... | |
~xbDate () | |
Destructor. More... | |
void | operator= (const xbDate &d) |
Set operator=. More... | |
void | operator+= (xbInt32 i) |
operator += More... | |
void | operator-= (xbInt32 i) |
operator -= More... | |
void | operator++ (xbInt32 i) |
operator ++ More... | |
void | operator-- (xbInt32 i) |
operator – More... | |
xbInt32 | operator- (const xbDate &) const |
operator - More... | |
const char * | operator- (xbInt32 i) |
operator - More... | |
const char * | operator+ (xbInt32 i) |
operator + More... | |
xbBool | operator== (const xbDate &) const |
operator == More... | |
xbBool | operator!= (const xbDate &) const |
operator != More... | |
xbBool | operator< (const xbDate &) const |
operator < More... | |
xbBool | operator> (const xbDate &) const |
> More... | |
xbBool | operator<= (const xbDate &) const |
operator <= More... | |
xbBool | operator>= (const xbDate &) const |
operator >= More... | |
xbInt16 | CalcRollingCenturyForYear (xbInt16 year) const |
Calculate century for a given year. More... | |
xbInt16 | CenturyOf () const |
Get century for date. More... | |
xbInt16 | CharDayOf (xbString &sOutCharDay) |
Get the day of the week. More... | |
xbInt16 | CharMonthOf (xbString &sOutCharMonth) |
Get the month from the date. More... | |
xbBool | DateIsValid (const xbString &sDate8) const |
Check a date for valid data. More... | |
xbInt16 | DayOf (xbInt16 iFormat) const |
xbInt16 | CTOD (const xbString &sCtodInDate) |
Format MM/DD/YY date. More... | |
xbInt16 | FormatDate (const xbString &sFmtIn, xbString &sFmtOut) |
const char * | Str () const |
Return the date value. More... | |
xbBool | IsLeapYear (xbInt16 iYear) const |
Determine if date is a leap year. More... | |
xbBool | IsLeapYear () const |
Determine if date is a leap year. More... | |
xbInt32 | JulianDays () const |
Calculate julian days for a given date. More... | |
xbInt16 | JulToDate8 (xbInt32 lJulDate) |
Convert the number of julian days to gregorian date. More... | |
xbInt16 | LastDayOfMonth () |
Set the date to the last day of month for a given date. More... | |
xbInt16 | MonthOf () const |
Return the month for the date. More... | |
xbInt16 | Set (const xbString &Date8) |
Set the date. More... | |
xbInt16 | Sysdate () |
Set the date equal to the system date. More... | |
xbInt16 | YearOf () const |
Returns the year of the date. More... | |
void | DisplayError (xbInt16 ErrorCode) const |
Display error message on console for a given error number. More... | |
xbString & | GetDefaultDateFormat () const |
Get the default date format. More... | |
xbString & | GetDataDirectory () const |
Get the current data directory. More... | |
xbInt16 | GetEndianType () const |
Get the Endian type. More... | |
const char * | GetErrorMessage (xbInt16 ErrorCode) const |
Get an error message. More... | |
void | SetDataDirectory (const xbString &sDataDirectory) |
Set the data directory. More... | |
void | SetDefaultDateFormat (const xbString &sDefaultDateFormat) |
Set the default date format. More... | |
xbBool | BitSet (unsigned char c, xbInt16 iBitNo) const |
Check a bit in a one byte field and see if it is set. More... | |
xbBool | GetDefaultAutoCommit () const |
Get the default auto commit setting. More... | |
void | SetDefaultAutoCommit (xbBool bDefaultAutoCommit) |
Set the default auto commit. More... | |
xbString & | GetDefaultLogDirectory () const |
xbString & | GetDefaultLogFileName () const |
void | SetDefaultLogDirectory (const xbString &sDefaultLogDirectory) |
xbBool | GetMultiUser () const |
Get the multi user setting. More... | |
void | SetMultiUser (xbBool bMultiUser) |
Get the multi user setting. More... | |
Static Public Attributes | |
static const char * | ErrorCodeText [] |
Protected Member Functions | |
void | SetEndianType () |
Set the endian type. More... | |
Static Protected Attributes | |
static xbInt16 | iEndianType = 0 |
static xbString | sNullString = "" |
xbDate class.
This xbDate class handles two type of date values:
1) Gregorian dates with a format of CCYYMMDD. This is how dates are stored in dbf files.
2) Julian dates calculated as the number of days since 1901-01-01 + 1721425.
Leap Years: The routines in the class support both leap years (one every four years) and leap centuries (one every four hundred years.)
A leap year is a year having 366 days, which can be evenly divisible by 4 and not by 100.
Leap centuries are years which are evenly divisible by 400.
From a programming perspective, Julian dates are useful for date arithmetic, determining the difference between two dates or calculating a future or past date.
To determine the difference between two dates, convert both dates to a Julian date and subtract one from the other.
To calculate a future or past date, convert the base date to a Julian date, add (or subtract) the number of days necessary to (from) it and convert the julian date back to a Gregorian date.
xb::xbDate::xbDate | ( | ) |
Constructor.
xb::xbDate::xbDate | ( | const char * | sDate8In | ) |
Constructor.
sDate8In | - Input date. |
xb::xbDate::xbDate | ( | const xbString & | sDate8In | ) |
Constructor.
sDate8In | - Input date. |
xb::xbDate::xbDate | ( | xbInt32 | lJulDate | ) |
Constructor.
lJulDate | - Input julian date. |
xb::xbDate::~xbDate | ( | ) |
Destructor.
|
inherited |
Check a bit in a one byte field and see if it is set.
c | One byte char field to examine. |
iBitNo | which bit to examine. |
xbInt16 xb::xbDate::CalcRollingCenturyForYear | ( | xbInt16 | iCalcYear | ) | const |
Calculate century for a given year.
This routine calculates a century for a given year. It uses an 80/20 rolling date window to calculate the century.
iCalcYear | - Two digit year to calculate a century for. |
xbInt16 xb::xbDate::CenturyOf | ( | ) | const |
Get century for date.
xbInt16 xb::xbDate::CharDayOf | ( | xbString & | sOutCharDay | ) |
Get the day of the week.
sOutCharDay | - Output character day of week (Sun-Sat). |
xbInt16 xb::xbDate::CharMonthOf | ( | xbString & | sOutCharMonth | ) |
Get the month from the date.
sOutCharMonth | - Output character month. |
xbInt16 xb::xbDate::CTOD | ( | const xbString & | sCtodInDate | ) |
Format MM/DD/YY date.
This routine takes an MM/DD/YY format date as input and populates a date class with the appropriate YYYYMMDD data.
sCtodInDate | - MM/DD/YY formatted date as input. |
Check a date for valid data.
sDateIn | - Date to check for valid formaat of CCYYMMDD. |
xbInt16 xb::xbDate::DayOf | ( | xbInt16 | iFormat | ) | const |
This routine returns the numeric day.
iFormat | XB_FMT_WEEK Number of day in WEEK 0-6 ( Sat - Fri ) XB_FMT_MONTH Number of day in MONTH 1-31 XB_FMT_YEAR Number of day in YEAR 1-366 |
|
inherited |
Display error message on console for a given error number.
iErrorCode | Error number to reference |
This routine will reformat a date based on the format specifiers entered in sFmtIn. If no input format is specified, the routine will use the system default date format.
sFmtIn | - A format specifier with the following paramaters:1) YYDDD - A julian date format 2) YY or YYYY will print a 2 or 4 digit year 3) M,MM,MMM or MMMM M - one digit month if no leading zero MM - two digit month, contains leading zero MMM - Jan through Dec MMMM - January through December 4) D,DD,DDD or DDDD D - one digit dayif no leading zero DD - two digit day, contains leading zero DDD - Sun through Sat (or julian if YYDDD) DDDD - Sunday through Saturday |
sOutFmtDate | - Reformatted output date. |
|
inherited |
Get the current data directory.
|
inherited |
Get the default auto commit setting.
When auto commit is enabled, the library will automatically post any updates when moving off an updated record or closing files. If auto commit is disabled, the application program will need to explicitly update the tables using using dbf->Put() and dbf->AppendRecord().
|
inherited |
Get the default date format.
|
inherited |
|
inherited |
|
inherited |
Get the Endian type.
|
inherited |
Get an error message.
iErrorCode | ErrorCode is the error number of description to be returned. |
|
inherited |
Get the multi user setting.
xbBool xb::xbDate::IsLeapYear | ( | ) | const |
Determine if date is a leap year.
xbBool xb::xbDate::IsLeapYear | ( | xbInt16 | iYear | ) | const |
Determine if date is a leap year.
iYear | - Year to check for leap year status. |
xbInt32 xb::xbDate::JulianDays | ( | ) | const |
Calculate julian days for a given date.
xbInt16 xb::xbDate::JulToDate8 | ( | xbInt32 | lJulDays | ) |
Convert the number of julian days to gregorian date.
lJulDays | - Julian days. |
xbInt16 xb::xbDate::LastDayOfMonth | ( | ) |
Set the date to the last day of month for a given date.
This routine sets the last date of the month.
xbInt16 xb::xbDate::MonthOf | ( | ) | const |
Return the month for the date.
operator !=
This routine compares two dates for inequality.
dt | - Date to compare. |
const char * xb::xbDate::operator+ | ( | xbInt32 | lCount | ) |
operator +
This routine adds additional days to a date field.
lCount | - Number of days to add. |
void xb::xbDate::operator++ | ( | xbInt32 | i | ) |
operator ++
This routine adds one day to the date field.
void xb::xbDate::operator+= | ( | xbInt32 | lDays | ) |
operator +=
This routine adds lDays to the date
lDays | - Number of days to add to the date. |
xbInt32 xb::xbDate::operator- | ( | const xbDate & | dt | ) | const |
operator -
This routine subtracts one date from another date returning the difference.
dt | - Date to subtract. |
const char * xb::xbDate::operator- | ( | xbInt32 | lCount | ) |
operator -
This routine subtracts days from a date field.
lCount | - Number of days to subtract. |
void xb::xbDate::operator-- | ( | xbInt32 | i | ) |
operator –
This routine subtracts one day from the date field.
void xb::xbDate::operator-= | ( | xbInt32 | lDays | ) |
operator -=
This routine subtracts lDays from the date.
lDays | - Number of days to subtract from the date. |
operator <
This routine compares two dates
dt | - Date to compare. |
operator <=
This routine compares two dates
dt | - Date to compare. |
void xb::xbDate::operator= | ( | const xbDate & | dt | ) |
Set operator=.
dt | - Date value for set operation. |
operator ==
This routine compares two dates for equality.
dt | - Date to compare. |
>
This routine compares two dates
dt | - Date to compare. |
operator >=
This routine compares two dates
dt | - Date to compare. |
xbInt16 xb::xbDate::Set | ( | const xbString & | sDateIn | ) |
Set the date.
sDateIn | - Input date. |
|
inherited |
Set the data directory.
sDataDirectory | Set the data direcroty. |
|
inherited |
Set the default auto commit.
Disabling auto commit requires the application execute explicit updates using dbf->Put() and dbf->AppendRecord(). With auto commit on, the library posts updates automatically when moving off the current record or closing a file.
bDefaultAutoCommit | xbTrue - Enable default auto commit. xbFalse - Disable default auto commit. |
|
inherited |
Set the default date format.
sDefaultDateFormat | Set the default date format. |
|
inherited |
|
protectedinherited |
Set the endian type.
This routine determines the Endian-ness at run time instead of compile time as some processers (ie; Sparc,ARM) can be switched either way. This routine is called automatically by the library at startup and does not need to be called in an application program.
|
inherited |
Get the multi user setting.
bMultiUser | xbTrue - Turn on Multi user mode. xbFalse - Turn off Multi user mode. |
const char * xb::xbDate::Str | ( | ) | const |
Return the date value.
xbInt16 xb::xbDate::Sysdate | ( | ) |
Set the date equal to the system date.
xbInt16 xb::xbDate::YearOf | ( | ) | const |
Returns the year of the date.
|
staticinherited |
|
staticprotectedinherited |
|
staticprotectedinherited |