Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Date Class Reference

#include <Date.h>

Inheritance diagram for Date:

Data List of all members.

Public Types

enum  CALENDAR { GREGORIAN, BUDDHIST_GREGORIAN, HIJRI }

Public Member Functions

 Date ()
 Date (const char *d)
 Date (const std::string &d)
 Date (const Date *d)
bool isMissing (void) const
void setMissing (void)
void set (const char *dateString)
void set (const std::string &dateString)
const std::string get (void) const
Dateoperator++ ()
Date operator++ (int)
Dateoperator-- ()
Date operator-- (int)
Dateoperator+= (const Number &b)
Dateoperator-= (const Number &b)
Date operator+ (const Number &b) const
Date operator- (const Number &b) const
Number operator- (const Date &b) const
bool operator< (const Data &b) const
bool operator== (const Data &b) const
bool isApproximate (void) const
const DATATYPE getDataType (void) const
virtual Dateclone () const

Static Public Member Functions

static void addDateMissingValue (std::string value)
static bool isMissingValue (std::string value)
static bool isA (const std::string &s)
static double getDaysInYear (void)
static void displayRangeMeans (bool displayThem)
static void displayDelimiters (bool displayThem)

Static Public Attributes

static const Date MISSING

Private Member Functions

long _yearMonthDayToJulian (int yyyy, int mm, int dd)
bool _isLeapYear (int year)
int _getLastDayOfMonth (int year, int month)
void _getYearMonthDay (const long julian, int *yyyy, int *mm, int *dd) const
long _islamicYearMonthDayToJulian (int yyyy, int mm, int dd) const
bool _isIslamicLeapYear (int year) const
int _lastDayOfIslamicMonth (int year, int month) const
void _getIslamicYearMonthDay (const long julian, int *yyyy, int *mm, int *dd) const
bool _intersectionIsNotNull (const Date &b) const
bool _hasASCIIDateDelimiter (const char **position)
bool _hasApproximationIndicator (const char **position)
bool _hasCJKCharacterForYear (const char **position)
bool _hasCJKCharacterForMonth (const char **position)
bool _hasCJKCharacterForDay (const char **position)
bool _hasCJKCharacterForArrive (const char **position)
bool _hasCJKCharacterForFullStop (const char **position)
bool _hasCJKCharacterForForwardSlash (const char **position)
bool _hasCJKCharacterForDash (const char **position)
bool _hasCJKCharacterForOpeningSquareBracket (const char **position)
bool _hasCJKCharacterForClosingSquareBracket (const char **position)
bool _hasUnicodeRightArrow (const char **position)
bool _hasKoreanHangulForYear (const char **position)
bool _hasKoreanHangulForMonth (const char **position)
bool _hasKoreanHangulForDay (const char **position)
bool _hasUTF8Character (const char **position, const char *UTF8Character)
bool _hasRangeDelimiter (const char **position, bool startBracketFound)
bool _hasCJKVersionOfGenericDateDelimiter (const char **position)
bool _hasYearDelimiter (const char **position, bool *isProperCJKDate)
bool _hasMonthDelimiter (const char **position)
bool _hasDayDelimiter (const char **position)
bool _hasOpeningBracket (const char **position)
bool _hasClosingBracket (const char **position)
int _getValue (const char **position)
void _skipWhiteSpace (const char **position)
void _readDateString (const char *s)
bool _yearIsValid (int year, const char *dateString)
bool _monthIsValid (int month, const char *dateString)
bool _dayIsValid (int year, int month, int day, const char *dateString)

Private Attributes

bool _isMissing
bool _isApproximate
bool _isRange
long _julian
long _highEndJulian

Static Private Attributes

static const int _daysInMonth [12] = {31,28,31,30,31,30,31,31,30,31,30,31}
static bool _displayRangeMeans = false
static bool _displayDelimiters = false
static const long _IGREG = (15+31L*(10+12L*1582))
static const long _IGREGJULIAN = 2299161
static const long _IHIJRIJULIAN = 1948438
static const unsigned int _DATESTRINGLENGTH = 72
static const double _DAYSINYEAR = 365.2425
static std::set< std::string > _dateMissingValue
static CALENDAR _calendarDisplayType = Date::GREGORIAN

Detailed Description

The Date class provides support for exact dates, approximate dates, and missing dates. Approximate dates can be either unranged approximations or, more common, ranged approximations. For example, the date string "1963" will be interpreted by the class constructor as a ranged date spanning from January 1, 1963 to December 31, 1963 inclusive. The date string " 1994-07" will be interpreted as a ranged date spanning July 01, 1994 to July 31, 1994 inclusive. In contrast, "1987-05-12" would be interpreted as an exact date and "2005-02-29" as a missing date (because there were only 28 days in February of 2005).

Dates are stored internally as Julian day numbers. Dates are expected to be input in ISO "YYYY-MM-DD" format. Note however that the constructor handles non-ASCII digits seamlessly: See the DigitConverter class for details.

For dates prior to the establishment of the Gregorian calendar in 1582, a proleptic calendar is used.

2005.09.19 TO-DO: ED, DECIDE WHAT TO DO ABOUT NON-GREGORIAN (BUDDHIST,HIJRI) INPUT AND OUTPUT IN THE DATE CLASS.


Member Enumeration Documentation

enum Date::CALENDAR
 

Enumerator:
GREGORIAN 
BUDDHIST_GREGORIAN 
HIJRI 


Constructor & Destructor Documentation

Date::Date  )  [inline]
 

Date::Date const char *  d  )  [inline]
 

Date::Date const std::string &  d  )  [inline]
 

Date::Date const Date d  ) 
 

Date::Date(const Date *d)

Copy construct a date from a const pointer to a date:


Member Function Documentation

bool Date::_dayIsValid int  year,
int  month,
int  day,
const char *  dateString
[private]
 

void Date::_getIslamicYearMonthDay const long  julian,
int *  yyyy,
int *  mm,
int *  dd
const [private]
 

_getIslamicYearMonthDay(): --> Only use if date is > _IHIJRIJULIAN (start of Islamic calendar)

int Date::_getLastDayOfMonth int  year,
int  month
[private]
 

_getLastDayOfMonth(): Returns the last day of the month of the given year.

int Date::_getValue const char **  position  )  [private]
 

_getValue()

Converts a string of digits, optionally prefixed by a '+' or '-', into an integer value:

void Date::_getYearMonthDay const long  julian,
int *  yyyy,
int *  mm,
int *  dd
const [private]
 

_getYearMonthDay(): Obtain the year, month, and day integers from a julian day number.

bool Date::_hasApproximationIndicator const char **  position  )  [private]
 

_hasApproximationIndicator()

If the string pointed to by "*position" starts with "~", then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

bool Date::_hasASCIIDateDelimiter const char **  position  )  [private]
 

_hasASCIIDateDelimiter()

If the string pointed to by "*position" starts with ".", "/", or "-", then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

bool Date::_hasCJKCharacterForArrive const char **  position  )  [private]
 

bool Date::_hasCJKCharacterForClosingSquareBracket const char **  position  )  [private]
 

bool Date::_hasCJKCharacterForDash const char **  position  )  [private]
 

bool Date::_hasCJKCharacterForDay const char **  position  )  [private]
 

_hasCJKCharacterForDay(const char **position):

If the string pointed to by "*position" starts with the CJKCharacter for day (日 in UTF8 format), then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

: e6 97 a5

bool Date::_hasCJKCharacterForForwardSlash const char **  position  )  [private]
 

bool Date::_hasCJKCharacterForFullStop const char **  position  )  [private]
 

bool Date::_hasCJKCharacterForMonth const char **  position  )  [private]
 

_hasCJKCharacterForMonth(const char **position):

If the string pointed to by "*position" starts with the CJKCharacter for month (月 in UTF8 format), then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

: e5 b9 b4

bool Date::_hasCJKCharacterForOpeningSquareBracket const char **  position  )  [private]
 

bool Date::_hasCJKCharacterForYear const char **  position  )  [private]
 

_hasCJKCharacterForYear(const char **position):

If the string pointed to by "*position" starts with the CJKCharacter for year (年 in UTF8 format), then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

: e5 b9 b4

bool Date::_hasCJKVersionOfGenericDateDelimiter const char **  position  )  [private]
 

bool Date::_hasClosingBracket const char **  position  )  [private]
 

bool Date::_hasDayDelimiter const char **  position  )  [private]
 

bool Date::_hasKoreanHangulForDay const char **  position  )  [private]
 

_hasKoreanHangulForDay(const char **position):

If the string pointed to by "*position" starts with the CJKCharacter for year (일 in UTF8 format), then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

: ec 9d bc

bool Date::_hasKoreanHangulForMonth const char **  position  )  [private]
 

_hasKoreanHangulForMonth(const char **position):

If the string pointed to by "*position" starts with the CJKCharacter for year (월 in UTF8 format), then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

: ec 9b 94

bool Date::_hasKoreanHangulForYear const char **  position  )  [private]
 

bool Date::_hasMonthDelimiter const char **  position  )  [private]
 

bool Date::_hasOpeningBracket const char **  position  )  [private]
 

bool Date::_hasRangeDelimiter const char **  position,
bool  startBracketFound
[private]
 

_hasRangeDelimiter(const char **position,bool startBracketFound):

If the string pointed to by "*position" starts with a valid range delimiter (" - ","r", "R", "", or "", then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

bool Date::_hasUnicodeRightArrow const char **  position  )  [private]
 

bool Date::_hasUTF8Character const char **  position,
const char *  UTF8Character
[private]
 

_hasUTF8Character:

If the string pointed to by "*position" starts with the character in UTF8Character, then the string pointer is incremented to point to the next character and true is returned. Otherwise, the pointer is not incremented and false is returned.

bool Date::_hasYearDelimiter const char **  position,
bool *  isProperCJKDate
[private]
 

bool Date::_intersectionIsNotNull const Date b  )  const [private]
 

bool Date::_isIslamicLeapYear int  year  )  const [private]
 

_isIslamicLeapYear(): Returns true if it is an Islamic Hijri leap year:

long Date::_islamicYearMonthDayToJulian int  yyyy,
int  mm,
int  dd
const [private]
 

_islamicYearMonthDayToJulian(): Obtain the Julian day number from an Islamic Hijri date:

bool Date::_isLeapYear int  year  )  [private]
 

_isLeapYear(): Determines if a Gregorian calendar year is a leap year.

int Date::_lastDayOfIslamicMonth int  year,
int  month
const [private]
 

_lastDayOfIslamicMonth(): Returns the number of days in the Islamic month.

bool Date::_monthIsValid int  month,
const char *  dateString
[private]
 

void Date::_readDateString const char *  s  )  [private]
 

void Date::_skipWhiteSpace const char **  position  )  [private]
 

bool Date::_yearIsValid int  year,
const char *  dateString
[private]
 

Checks for errors in year yyyy, month mm, day dd for Gregorian civil calendar:

long Date::_yearMonthDayToJulian int  yyyy,
int  mm,
int  dd
[private]
 

_yearMonthDayToJulian(): Converts Gregorian civil year yyyy, month mm, day dd to Julian day number:

static void Date::addDateMissingValue std::string  value  )  [inline, static]
 

Date * Date::clone  )  const [virtual]
 

clone method:

Implements Data.

void Date::displayDelimiters bool  displayThem  )  [static]
 

void Date::displayRangeMeans bool  displayThem  )  [static]
 

const std::string Date::get void   )  const [virtual]
 

Get string representation of the date:

UNFINISHED: ostringstream may be SLOW : test and change

Implements Data.

const DATATYPE Date::getDataType void   )  const [inline, virtual]
 

Implements Data.

static double Date::getDaysInYear void   )  [inline, static]
 

bool Date::isA const std::string &  s  )  [static]
 

This is a static method: Determines if the presented string is a valid Date.

bool Date::isApproximate void   )  const [inline]
 

bool Date::isMissing void   )  const [virtual]
 

bool isMissing(): Required by virtual base class:

Implements Data.

bool Date::isMissingValue std::string  value  )  [static]
 

isMissingValue determines whether a string represents one of the missing values in the missing value lookup table.

Date Date::operator+ const Number n  )  const
 

operator+():

Date Date::operator++ int   ) 
 

Postfix ++

Date & Date::operator++  ) 
 

Prefix ++

Date & Date::operator+= const Number b  ) 
 

operator+=

Number Date::operator- const Date d  )  const
 

operator-():

Date Date::operator- const Number n  )  const
 

operator-():

Date Date::operator-- int   ) 
 

Postfix --

Date & Date::operator--  ) 
 

Prefix --

Date & Date::operator-= const Number b  ) 
 

operator -=

bool Date::operator< const Data b  )  const [virtual]
 

operator <

NOTA BENE: This is used for SORTING only

Implements Data.

bool Date::operator== const Data b  )  const [virtual]
 

operator ==

Implements Data.

void Date::set const std::string &  dateString  )  [virtual]
 

Set date from std::string:

Implements Data.

void Date::set const char *  dateString  )  [virtual]
 

Set a date from a "yyyy.mm.dd" string or a date range string.

Implements Data.

void Date::setMissing void   )  [virtual]
 

setMissing:

Implements Data.


Member Data Documentation

Date::CALENDAR Date::_calendarDisplayType = Date::GREGORIAN [static, private]
 

std::set< std::string > Date::_dateMissingValue [static, private]
 

const unsigned int Date::_DATESTRINGLENGTH = 72 [static, private]
 

const int Date::_daysInMonth = {31,28,31,30,31,30,31,31,30,31,30,31} [static, private]
 

const double Date::_DAYSINYEAR = 365.2425 [static, private]
 

bool Date::_displayDelimiters = false [static, private]
 

bool Date::_displayRangeMeans = false [static, private]
 

long Date::_highEndJulian [private]
 

const long Date::_IGREG = (15+31L*(10+12L*1582)) [static, private]
 

const long Date::_IGREGJULIAN = 2299161 [static, private]
 

const long Date::_IHIJRIJULIAN = 1948438 [static, private]
 

bool Date::_isApproximate [private]
 

bool Date::_isMissing [private]
 

bool Date::_isRange [private]
 

long Date::_julian [private]
 

const Date Date::MISSING [static]
 


The documentation for this class was generated from the following files:
Generated on Fri Nov 18 16:24:39 2011 for MADELINE by  doxygen 1.4.4