#include <DataType.h>
Public Member Functions | |
Date () | |
Date (JulianRep julian) | |
Date (int year, int month, int day) | |
constructor with year, month, day | |
Date (const Date &d2) | |
Date & | operator= (const Date &d2) |
int | set (int year, int month, int day) |
sets the date with specified year, month, day | |
int | set (const struct tm *tmptr) |
int | get (int &year, int &month, int &day) const |
get year, month, day of the date | |
bool | isValid () const |
checks for the validity of the date | |
void | setNull () |
resets the date to zero | |
int | dayOfWeek () const |
returns day of the week | |
const char * | dayOfWeekName () const |
returns day of the week. | |
const char * | dayOfWeekAbbr () const |
returns day of the week abbreviation values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" | |
int | dayOfMonth () const |
returns the day of the month. | |
int | dayOfYear () const |
int | month () const |
returns the month Values are 1 to 12. | |
const char * | monthName () const |
returns the month name values are "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" | |
const char * | monthAbbr () const |
returns the month name abbreviation values are "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" | |
int | parseFrom (const char *s) |
parses the date string passed and stores it It should of the format "mm/dd/yyyy" | |
Date & | operator++ () |
Date & | operator-- () |
Date & | operator+= (int days) |
Date & | operator-= (int days) |
int | year () const |
returns the year | |
Static Public Member Functions | |
static const char * | dayOfWeekName (int day) |
returns day of the week. | |
static const char * | dayOfWeekAbbr (int day) |
returns day of the week abbreviation values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" | |
static int | dayOfWeek (JulianRep juldate) |
static const char * | monthName (int month) |
returns the month name values are "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" | |
static const char * | monthAbbr (int month) |
returns the month name abbreviation values are "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" | |
static bool | isValidDate (int year, int month, int day) |
checks for the validity of the date | |
static bool | isLeapYear (int year) |
checks for leap year | |
static int | daysInMonth (int month, int year) |
returns the number of days in the specified month of the year. | |
static int | YMDToJulian (int year, int mon, int day, JulianRep &julian) |
static int | julianToYMD (JulianRep julian, int &year, int &month, int &day) |
Friends | |
Date | operator+ (const Date &d1, int days) |
Date | operator+ (int days, const Date &d1) |
Date | operator- (const Date &d1, int days) |
int | operator- (const Date &d1, const Date &d2) |
int | operator< (const Date &d1, const Date &d2) |
int | operator> (const Date &d1, const Date &d2) |
int | operator<= (const Date &d1, const Date &d2) |
int | operator>= (const Date &d1, const Date &d2) |
int | operator== (const Date &d1, const Date &d2) |
int | operator!= (const Date &d1, const Date &d2) |
Definition at line 191 of file DataType.h.
Date::Date | ( | ) | [inline] |
Date::Date | ( | JulianRep | julian | ) | [inline] |
Date::Date | ( | int | year, | |
int | month, | |||
int | day | |||
) |
constructor with year, month, day
year | year | |
month | month | |
day | day |
Definition at line 21 of file DataType.cxx.
References YMDToJulian().
00022 { YMDToJulian(year, month, day, julianDate); }
Here is the call graph for this function:
Date::Date | ( | const Date & | d2 | ) | [inline] |
Definition at line 204 of file DataType.h.
References julianDate.
00204 { julianDate = d2.julianDate; }
int Date::dayOfMonth | ( | ) | const |
returns the day of the month.
Values are 1 to 31
Definition at line 41 of file DataType.cxx.
References get(), month(), and year().
Referenced by AllDataType::convertToString(), TimeStamp::dayOfMonth(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getDate(), and AllDataType::printVal().
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::dayOfWeek | ( | JulianRep | juldate | ) | [static] |
int Date::dayOfWeek | ( | ) | const |
returns day of the week
Definition at line 57 of file DataType.cxx.
Referenced by TimeStamp::dayOfWeek(), dayOfWeekAbbr(), and dayOfWeekName().
00057 { return dayOfWeek(julianDate); }
Here is the caller graph for this function:
const char * Date::dayOfWeekAbbr | ( | int | day | ) | [static] |
returns day of the week abbreviation values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
Definition at line 92 of file DataType.cxx.
References day_abbrs.
00093 { return (day < 1 || day > 7) ? 0 : day_abbrs[day-1]; }
const char * Date::dayOfWeekAbbr | ( | ) | const |
returns day of the week abbreviation values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
Definition at line 62 of file DataType.cxx.
References dayOfWeek().
Referenced by TimeStamp::dayOfWeekAbbr().
00063 { return dayOfWeekAbbr(dayOfWeek(julianDate)); }
Here is the call graph for this function:
Here is the caller graph for this function:
const char * Date::dayOfWeekName | ( | int | day | ) | [static] |
returns day of the week.
values are "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday".
Definition at line 89 of file DataType.cxx.
References day_names.
00090 { return (day < 1 || day > 7) ? 0 : day_names[day-1]; }
const char * Date::dayOfWeekName | ( | ) | const |
returns day of the week.
values are "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday".
Definition at line 59 of file DataType.cxx.
References dayOfWeek().
Referenced by TimeStamp::dayOfWeekName().
00060 { return dayOfWeekName(dayOfWeek(julianDate)); }
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::dayOfYear | ( | ) | const |
Definition at line 132 of file DataType.cxx.
References daysBeforeMonth, get(), isLeapYear(), month(), and year().
Referenced by TimeStamp::dayOfYear().
00132 { 00133 int year,month,day; 00134 get(year,month,day); 00135 int tmp = daysBeforeMonth[month-1]; 00136 if (month >= 3 && isLeapYear(year)) 00137 tmp++; 00138 return tmp + day; 00139 }
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::daysInMonth | ( | int | month, | |
int | year | |||
) | [static] |
returns the number of days in the specified month of the year.
Definition at line 141 of file DataType.cxx.
References days_per_month, and isLeapYear().
Referenced by isValidDate().
00141 { 00142 --month; 00143 int tmp = days_per_month[month]; 00144 if (month == 1 && isLeapYear(year)) tmp++; 00145 return tmp; 00146 }
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::get | ( | int & | year, | |
int & | month, | |||
int & | day | |||
) | const |
get year, month, day of the date
year | year IN | |
month | month IN | |
day | day IN |
Definition at line 25 of file DataType.cxx.
References julianToYMD().
Referenced by dayOfMonth(), dayOfYear(), TimeStamp::getDate(), month(), and year().
00026 { return julianToYMD(julianDate,year,month,day); }
Here is the call graph for this function:
Here is the caller graph for this function:
bool Date::isLeapYear | ( | int | year | ) | [static] |
checks for leap year
Definition at line 127 of file DataType.cxx.
Referenced by dayOfYear(), and daysInMonth().
Here is the caller graph for this function:
bool Date::isValid | ( | ) | const |
checks for the validity of the date
Definition at line 124 of file DataType.cxx.
References SmallestValJulDate.
Referenced by TimeStamp::isValid().
00125 { return julianDate >= SmallestValJulDate; }
Here is the caller graph for this function:
bool Date::isValidDate | ( | int | year, | |
int | month, | |||
int | day | |||
) | [static] |
checks for the validity of the date
Definition at line 148 of file DataType.cxx.
References daysInMonth().
Referenced by TimeStamp::parseFrom(), parseFrom(), and YMDToJulian().
00148 { 00149 if (year < 1 || year > 10000) return false; 00150 if (month < 1 || month > 12) return false; 00151 return (day >= 1) && (day <= daysInMonth(month,year)); 00152 }
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::julianToYMD | ( | JulianRep | julian, | |
int & | year, | |||
int & | month, | |||
int & | day | |||
) | [static] |
Definition at line 180 of file DataType.cxx.
References SmallestValJulDate.
Referenced by get().
00180 { 00181 int j = jul; 00182 int d, m, y; 00183 00184 if (j < SmallestValJulDate) 00185 { year = month = day = 0; return -1; } 00186 00187 j -= 1721119; 00188 y = (4 * j - 1)/146097; 00189 j = 4 * j - 1 - 146097 * y; 00190 d = j/4; 00191 j = (4 * d + 3)/1461; 00192 d = 4 * d + 3 - 1461 * j; 00193 d = (d + 4)/4; 00194 m = (5 * d - 3)/153; 00195 d = 5 * d - 3 - 153 * m; 00196 d = (d + 5) / 5; 00197 y = 100 * y + j; 00198 if (m < 10) m += 3; 00199 else { m -= 9; ++y; } 00200 month = m; 00201 day = d; 00202 year = y; 00203 return 0; 00204 }
Here is the caller graph for this function:
int Date::month | ( | ) | const |
returns the month Values are 1 to 12.
Definition at line 46 of file DataType.cxx.
Referenced by AllDataType::convertToString(), dayOfMonth(), dayOfYear(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getDate(), TimeStamp::month(), monthAbbr(), monthName(), parseFrom(), AllDataType::printVal(), and year().
Here is the call graph for this function:
Here is the caller graph for this function:
const char * Date::monthAbbr | ( | int | month | ) | [static] |
returns the month name abbreviation values are "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
Definition at line 99 of file DataType.cxx.
References month_abbrs.
00100 { return (month < 1 || month > 12) ? 0 : month_abbrs[month-1]; }
const char * Date::monthAbbr | ( | ) | const |
returns the month name abbreviation values are "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
Definition at line 96 of file DataType.cxx.
References month().
Referenced by TimeStamp::monthAbbr().
Here is the call graph for this function:
Here is the caller graph for this function:
const char * Date::monthName | ( | int | month | ) | [static] |
returns the month name values are "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
Definition at line 97 of file DataType.cxx.
References month_names.
00098 { return (month < 1 || month > 12) ? 0 : month_names[month-1]; }
const char * Date::monthName | ( | ) | const |
returns the month name values are "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
Definition at line 95 of file DataType.cxx.
References month().
Referenced by TimeStamp::monthName().
Here is the call graph for this function:
Here is the caller graph for this function:
Date& Date::operator++ | ( | ) | [inline] |
Date& Date::operator+= | ( | int | days | ) | [inline] |
Date& Date::operator-- | ( | ) | [inline] |
Date& Date::operator-= | ( | int | days | ) | [inline] |
Definition at line 205 of file DataType.h.
References julianDate.
00206 { julianDate=d2.julianDate; return *this; }
int Date::parseFrom | ( | const char * | s | ) |
parses the date string passed and stores it It should of the format "mm/dd/yyyy"
Definition at line 28 of file DataType.cxx.
References isValidDate(), month(), set(), and year().
Referenced by AllDataType::convertToDate(), and TimeStamp::parseDateFrom().
00028 { 00029 int month,day,year; 00030 int count; 00031 count = sscanf(s,"%d/%d/%d",&year,&month,&day); 00032 if (count < 3) return -1; 00033 00034 if (year < 100) year += 1900; 00035 00036 if (!isValidDate(year, month, day)) 00037 return -1; 00038 return set(year,month,day); 00039 }
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::set | ( | const struct tm * | tmptr | ) |
int Date::set | ( | int | year, | |
int | month, | |||
int | day | |||
) |
sets the date with specified year, month, day
year | year | |
month | month | |
day | day |
Definition at line 23 of file DataType.cxx.
References YMDToJulian().
Referenced by copyFromOdbc(), SqlOdbcStatement::fetch(), SqlOdbcStatement::fetchAndPrint(), CacheTableLoader::load(), parseFrom(), and TimeStamp::setDate().
00024 { return YMDToJulian(year,month,day,julianDate); }
Here is the call graph for this function:
Here is the caller graph for this function:
void Date::setNull | ( | ) | [inline] |
resets the date to zero
Definition at line 229 of file DataType.h.
Referenced by TimeStamp::setNull().
Here is the caller graph for this function:
int Date::year | ( | ) | const |
returns the year
Definition at line 51 of file DataType.cxx.
References get(), and month().
Referenced by AllDataType::convertToString(), dayOfMonth(), dayOfYear(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getDate(), month(), parseFrom(), AllDataType::printVal(), and TimeStamp::year().
Here is the call graph for this function:
Here is the caller graph for this function:
int Date::YMDToJulian | ( | int | year, | |
int | mon, | |||
int | day, | |||
JulianRep & | julian | |||
) | [static] |
Definition at line 155 of file DataType.cxx.
References isValidDate().
Referenced by Date(), and set().
00155 { 00156 if (!isValidDate(year, mon, day)) 00157 { jul = (JulianRep)0; return -1; } 00158 00159 // year, month, day are assumed to be valid 00160 int m = mon, d = day, y = year; 00161 int c, ya, j; 00162 00163 if (m > 2) m -= 3; 00164 else { m += 9; --y; } 00165 c = y/100; 00166 ya = y - (100 * c); 00167 j = (146097*c)/4 + (1461*ya)/4 + (153*m+2)/5 + d + 1721119; 00168 jul = (JulianRep)j; 00169 return 0; 00170 }
Here is the call graph for this function:
Here is the caller graph for this function: