#

Date Methods

Chapter Updated 2/1/99

This chapter lists the date methods and provides examples of how to use them.
All references to Date8 refer to a date with the format of CCYYMMDD.

### Xbase Date Method List

Method | Description
char * CharDayOf(char *Date8) | Returns pointer to (Sun - Sat) day of week
char * CharMonthOf(char *Date8) | Returns pointer to (Jan - Dec) month of year
xbShort DateIsValid(char *Date8) | Checks a date for validity
xbShort DayOf(char *Date8) | Returns the "day of WEEK, MONTH or YEAR" from a given date
char * FormatDate(char *fmt,char *Date8) | Return a pointer to a formatted date
xbShort IsLeapYear(char *Date8) | Returns TRUE if given date is a leap year
xbLong JulianDays(char *Date8) | Returns number of days since 1/1/1900 to given date
char * JulToDate8(xbLong Days) | Converts Julian date to CCYYMMDD format
xbLong LastDayOfMonth(char *Date8) | Returns julian day for the last day of the month for a given date.
xbShort MonthOf(char *Date8) | Returns month of a date
char * Sysdate() | Returns a pointer to the system date
xbShort YearOf(char *Date8) | Returns century and year of a date

## Method Definitions

### Method: char * xbXBase::CharDayOf( char * Date8 )

#### Inputs:

Date8 - A valid date with the format of CCYYMMDD

#### Returns:

A pointer to static buffer containing the spelling of the day of the week (Monday-Sunday)

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: char * xbXBase::CharMonthOf( char * Date8 )

#### Inputs:

Date8 - A valid date with the format of CCYYMMDD

#### Returns:

A pointer to static buffer contianing the spelling of the month (January-December)

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: xbShort xbXBase::DateIsValid( char * Date8 )

#### Inputs:

Date8 - A valid date with the format CCYYMMDD

#### Returns:

This method returns 1 if the input date is a valid date, otherwise it returns 0.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: xbShort xbXBase::DayOf( xbShort Format, char * Date8 )

#### Inputs:

     Valid values for Format are:

          WEEK   for the day of the week (0 - Sunday through 6 - Saturday)
          MONTH  for the day of the month (1-31)
          YEAR   for the day of the year (1-366)

    Beginning with release 1.7.4,  WEEK is now FMT_WEEK
                                   MONTH is now FMT_MONTH
                                   YEAR is now FMT_YEAR

     Date8 - A valid date with the format CCYYMMDD

#### Processing:

Based on the format type, calculate the day of the week, month or year.

#### Returns:

This method returns the day of the year as an integer.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: char * xbXBase::FormatDate( char * Format, char * Date8 )

#### Inputs:

          Format - 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

Date8 - A valid date with the format CCYYMMDD

#### Returns:

A pointer to a static buffer which contains the reformatted date. If the input format is an unknown type, the function returns the same date recieved.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: xbShort xbXBase::IsLeapYear( char * Date8 )

#### Inputs:

Date8 - A valid date with the format CCYYMMDD

#### Returns:

This method returns 1 if the input date is a leap year, otherwise it returns 0.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: xbLong xbXBase::JulianDays( char * Date8 )

#### Inputs:

Date8 - A valid date with the format CCYYMMDD

#### Returns:

This method returns the number or of days since 19000101.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: char * xbXBase::JulToDate8( xbLong Days )

This method is the compliment of method JulianDays.

#### Inputs:

Days - A julian count of days since 19010101

#### Returns:

A date with the format of CCYYMMDD

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method: xbLong xbXBase::LastDayOfMonth( char * Date8 )

#### Inputs:

Date8 - A valid date with the format CCYYMMDD

#### Returns:

This method returns the julina day for the last day of the month for the given input date.

### Method: xbShort xbXBase::MonthOf( char * Date8 )

#### Inputs:

Date8 - A valid date with the format CCYYMMDD

#### Returns:

This method returns the MM part of the date as an integer.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method char * xbXBase::Sysdate()

#### Returns:

This method returns a pointer to a static buufer which contains the system date in CCYYMMDD format.

#### Example:

See program testdate.cpp for an example of how to use this method.

### Method xbShort xbXBase::YearOf( char * Date8 )

#### Inputs:

Date8 - A valid date with the format CCYYMMDD

#### Returns:

This method returns the CCYY part of the date as an integer.

#### Example:

See program testdate.cpp for an example of how to use this method.

Send me mail - xbase@startech.keller.tx.us

(c)1997 StarTech