TimeStamp Class Reference

Represents TimeStamp Data type. More...

#include <DataType.h>

Collaboration diagram for TimeStamp:

Collaboration graph
[legend]

Public Member Functions

 TimeStamp ()
 TimeStamp (int year, int month, int day, int hour, int minute, int sec, int usec=0)
 Overloaded constructor.
 TimeStamp (const TimeStamp &ts)
 TimeStamp (const Date &d, Time &t)
TimeStampoperator= (const TimeStamp &d2)
int getDate (int &year, int &month, int &day)
 get year, month, day from the date part of the timestamp
void getDate (Date &newDate) const
 get the date part of the timestamp
int setDate (int year, int month, int day)
 sets the date with specified year, month, day
void setDate (const Date &newDate)
 set the date part of the timestamp
 operator Date ()
 operator Time ()
int getTime (int &hours, int &mins, int &secs) const
 retrieves the time using IN parameters
void getTime (Time &newTime) const
 retrieves the time part of the timestamp
int setTime (int hours, int mins, int secs, int usec=0)
 sets the time with specified hours, mins, secs
void setTime (const Time &newTime)
 set the time part of the timestamp
bool isValid () const
 checks for the validity of the timestamp
void setNull ()
 resets the date and time
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.
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 year () const
 returns the year
int secondsSinceMidnight () const
int seconds () const
 returns the seconds
int minutes () const
 returns the minutes
int hours () const
 returns the hours
int msec () const
 returns the millisecs
int usec () const
 returns the microsecs
int setMsec (int ms)
 sets the millisecs
int setUsec (int us)
 sets the microsecs
int parseDateFrom (const char *s)
 parses the date string passed and stores it It should of the format "mm/dd/yyyy"
int parseTimeFrom (const char *s)
 parses the time string passed and stores it It should of the format "hh:mm::ss"
int parseFrom (const char *s)

Friends

int operator< (const TimeStamp &d1, const TimeStamp &d2)
int operator> (const TimeStamp &d1, const TimeStamp &d2)
int operator<= (const TimeStamp &d1, const TimeStamp &d2)
int operator>= (const TimeStamp &d1, const TimeStamp &d2)
int operator== (const TimeStamp &d1, const TimeStamp &d2)
int operator!= (const TimeStamp &d1, const TimeStamp &d2)

Detailed Description

Represents TimeStamp Data type.


Author:
Prabakaran Thirumalai

Definition at line 454 of file DataType.h.


Constructor & Destructor Documentation

TimeStamp::TimeStamp (  )  [inline]

Definition at line 457 of file DataType.h.

00457 {}

TimeStamp::TimeStamp ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  sec,
int  usec = 0 
) [inline]

Overloaded constructor.

Parameters:
year year
month month
day day
hours hours
mins mins
secs secs
usec usec

Definition at line 468 of file DataType.h.

00468                                                                                          :
00469         date(year, month, day), time(hour, minute, sec, usec) { }

TimeStamp::TimeStamp ( const TimeStamp ts  )  [inline]

Definition at line 471 of file DataType.h.

References date, and time.

00472     { date = ts.date; time = ts.time; }

TimeStamp::TimeStamp ( const Date d,
Time t 
) [inline]

Definition at line 473 of file DataType.h.

00473 : date(d), time(t) {}


Member Function Documentation

int TimeStamp::dayOfMonth (  )  const [inline]

returns the day of the month.

Values are 1 to 31

Definition at line 565 of file DataType.h.

References Date::dayOfMonth().

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTimestamp(), and AllDataType::printVal().

00565 { return date.dayOfMonth(); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::dayOfWeek (  )  const [inline]

returns day of the week.

Values are 1-7

Definition at line 550 of file DataType.h.

References Date::dayOfWeek().

00550 { return date.dayOfWeek(); }

Here is the call graph for this function:

const char* TimeStamp::dayOfWeekAbbr (  )  const [inline]

returns day of the week abbreviation values are "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"

Definition at line 561 of file DataType.h.

References Date::dayOfWeekAbbr().

00561 { return date.dayOfWeekAbbr(); }

Here is the call graph for this function:

const char* TimeStamp::dayOfWeekName (  )  const [inline]

returns day of the week.

values are "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Satur day".

Definition at line 556 of file DataType.h.

References Date::dayOfWeekName().

00556 { return date.dayOfWeekName(); }

Here is the call graph for this function:

int TimeStamp::dayOfYear (  )  const [inline]

Definition at line 566 of file DataType.h.

References Date::dayOfYear().

00566 { return date.dayOfYear(); }

Here is the call graph for this function:

void TimeStamp::getDate ( Date newDate  )  const [inline]

get the date part of the timestamp

Parameters:
Date date

Definition at line 490 of file DataType.h.

00491          { newDate = date; }

int TimeStamp::getDate ( int &  year,
int &  month,
int &  day 
) [inline]

get year, month, day from the date part of the timestamp

Parameters:
year year IN
month month IN
day day IN

Definition at line 484 of file DataType.h.

References Date::get().

00485          { return date.get(year, month, day); }

Here is the call graph for this function:

void TimeStamp::getTime ( Time newTime  )  const [inline]

retrieves the time part of the timestamp

Parameters:
newTime Time

Definition at line 523 of file DataType.h.

00524          { newTime = time; }

int TimeStamp::getTime ( int &  hours,
int &  mins,
int &  secs 
) const [inline]

retrieves the time using IN parameters

Parameters:
hours hours
mins mins
secs secs

Definition at line 518 of file DataType.h.

References Time::get().

00519          { return time.get(hours, mins, secs); }

Here is the call graph for this function:

int TimeStamp::hours (  )  const [inline]

returns the hours

Definition at line 595 of file DataType.h.

References Time::hours().

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTimestamp(), parseFrom(), and AllDataType::printVal().

00595 { return time.hours(); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool TimeStamp::isValid (  )  const [inline]

checks for the validity of the timestamp

Definition at line 543 of file DataType.h.

References Time::isValid(), and Date::isValid().

00543 { return date.isValid() && time.isValid(); }

Here is the call graph for this function:

int TimeStamp::minutes (  )  const [inline]

returns the minutes

Definition at line 593 of file DataType.h.

References Time::minutes().

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTimestamp(), and AllDataType::printVal().

00593 { return time.minutes(); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::month (  )  const [inline]

returns the month.

Values are 1 to 12.

Definition at line 571 of file DataType.h.

References Date::month().

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTimestamp(), parseFrom(), and AllDataType::printVal().

00571 { return date.month(); }

Here is the call graph for this function:

Here is the caller graph for this function:

const char* TimeStamp::monthAbbr (  )  const [inline]

returns the month name abbreviation Values are "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"

Definition at line 583 of file DataType.h.

References Date::monthAbbr().

00583 { return date.monthAbbr(); }

Here is the call graph for this function:

const char* TimeStamp::monthName (  )  const [inline]

returns the month name values are "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"

Definition at line 577 of file DataType.h.

References Date::monthName().

00577 { return date.monthName(); }

Here is the call graph for this function:

int TimeStamp::msec (  )  const [inline]

returns the millisecs

Definition at line 597 of file DataType.h.

References Time::msec().

00597 { return time.msec(); }

Here is the call graph for this function:

TimeStamp::operator Date (  )  [inline]

Definition at line 508 of file DataType.h.

00508 { return date; }

TimeStamp::operator Time (  )  [inline]

Definition at line 509 of file DataType.h.

00509 { return time; }

TimeStamp& TimeStamp::operator= ( const TimeStamp d2  )  [inline]

Definition at line 476 of file DataType.h.

References date, and time.

00477         { date=d2.date; time = d2.time; return *this; }

int TimeStamp::parseDateFrom ( const char *  s  )  [inline]

parses the date string passed and stores it It should of the format "mm/dd/yyyy"

Definition at line 609 of file DataType.h.

References Date::parseFrom().

00609 { return date.parseFrom(s); }

Here is the call graph for this function:

int TimeStamp::parseFrom ( const char *  s  ) 

Definition at line 291 of file DataType.cxx.

References hours(), Date::isValidDate(), Time::isValidTime(), month(), setDate(), setTime(), and year().

Referenced by AllDataType::convertToTimeStamp().

00291                                       {
00292     int hours,mins,secs;
00293     int month,day,year;
00294     int count;
00295     count = sscanf(s,"%d/%d/%d %d:%d:%d",&year,&month,&day, &hours, &mins, &secs);
00296     if (count < 5) return -1;
00297     if (count == 5) secs = 0;
00298 
00299     if (year < 100) year += 1900;
00300 
00301     if (!date.isValidDate(year, month, day))
00302         return -1;
00303 
00304     setDate(year,month,day);
00305 
00306 
00307     if (!time.isValidTime(hours,mins,secs))
00308         return -1;
00309     return setTime(hours,mins,secs);
00310 }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::parseTimeFrom ( const char *  s  )  [inline]

parses the time string passed and stores it It should of the format "hh:mm::ss"

Definition at line 615 of file DataType.h.

References Time::parseFrom().

00615 { return time.parseFrom(s); }

Here is the call graph for this function:

int TimeStamp::seconds (  )  const [inline]

returns the seconds

Definition at line 591 of file DataType.h.

References Time::seconds().

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTimestamp(), and AllDataType::printVal().

00591 { return time.seconds(); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::secondsSinceMidnight (  )  const [inline]

Definition at line 589 of file DataType.h.

References Time::secondsSinceMidnight().

00589 { return time.secondsSinceMidnight(); }

Here is the call graph for this function:

void TimeStamp::setDate ( const Date newDate  )  [inline]

set the date part of the timestamp

Parameters:
Date date

Definition at line 504 of file DataType.h.

00505          { date = newDate; }

int TimeStamp::setDate ( int  year,
int  month,
int  day 
) [inline]

sets the date with specified year, month, day

Parameters:
year year
month month
day day

Definition at line 498 of file DataType.h.

References Date::set().

Referenced by copyFromOdbc(), SqlOdbcStatement::fetch(), SqlOdbcStatement::fetchAndPrint(), CacheTableLoader::load(), and parseFrom().

00499          { return date.set(year, month, day); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::setMsec ( int  ms  )  [inline]

sets the millisecs

Definition at line 602 of file DataType.h.

References Time::setMsec().

00602 { return time.setMsec(ms) ; }

Here is the call graph for this function:

void TimeStamp::setNull (  )  [inline]

resets the date and time

Definition at line 546 of file DataType.h.

References Time::setNull(), and Date::setNull().

00546 { date.setNull(); time.setNull(); }

Here is the call graph for this function:

void TimeStamp::setTime ( const Time newTime  )  [inline]

set the time part of the timestamp

Parameters:
newTime Time

Definition at line 538 of file DataType.h.

00539          { time = newTime; }

int TimeStamp::setTime ( int  hours,
int  mins,
int  secs,
int  usec = 0 
) [inline]

sets the time with specified hours, mins, secs

Parameters:
hours hours
mins mins
secs secs
usec usec

Definition at line 532 of file DataType.h.

References Time::set(), and usec().

Referenced by copyFromOdbc(), SqlOdbcStatement::fetch(), SqlOdbcStatement::fetchAndPrint(), CacheTableLoader::load(), and parseFrom().

00533          { return time.set(hours, mins, secs, usec); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::setUsec ( int  us  )  [inline]

sets the microsecs

Definition at line 604 of file DataType.h.

References Time::setUsec().

00604 { return time.setUsec(us) ; }

Here is the call graph for this function:

int TimeStamp::usec (  )  const [inline]

returns the microsecs

Definition at line 599 of file DataType.h.

References Time::usec().

Referenced by setTime().

00599 { return time.usec(); }

Here is the call graph for this function:

Here is the caller graph for this function:

int TimeStamp::year (  )  const [inline]

returns the year

Definition at line 587 of file DataType.h.

References Date::year().

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTimestamp(), parseFrom(), and AllDataType::printVal().

00587 { return date.year(); }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

int operator!= ( const TimeStamp d1,
const TimeStamp d2 
) [friend]

Definition at line 322 of file DataType.cxx.

00323     { return d1.date != d2.date && d1.time != d2.time; }

int operator< ( const TimeStamp d1,
const TimeStamp d2 
) [friend]

Definition at line 312 of file DataType.cxx.

00313     { return (d1.date != d2.date) ? d1.date < d2.date : d1.time < d2.time; }

int operator<= ( const TimeStamp d1,
const TimeStamp d2 
) [friend]

Definition at line 316 of file DataType.cxx.

00317     { return (d1.date != d2.date) ? d1.date < d2.date : d1.time <= d2.time; }

int operator== ( const TimeStamp d1,
const TimeStamp d2 
) [friend]

Definition at line 320 of file DataType.cxx.

00321     { return d1.date == d2.date && d1.time == d2.time; }

int operator> ( const TimeStamp d1,
const TimeStamp d2 
) [friend]

Definition at line 314 of file DataType.cxx.

00315     { return (d1.date != d2.date) ? d1.date > d2.date : d1.time > d2.time; }

int operator>= ( const TimeStamp d1,
const TimeStamp d2 
) [friend]

Definition at line 318 of file DataType.cxx.

00319     { return (d1.date != d2.date) ? d1.date > d2.date : d1.time >= d2.time; }


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:54:45 2008 for csql by  doxygen 1.4.7