Time Class Reference

Represents Time Data type. More...

#include <DataType.h>


Public Member Functions

 Time ()
 Time (int hours, int mins, int secs, int usec=0)
 Overloaded constructor.
 Time (int totalSecs)
 Time (const Time &d2)
Timeoperator= (const Time &d2)
int set (int hours, int mins, int secs, int usec=0)
 sets the time with specified hours, mins, secs
int get (int &hours, int &mins, int &secs) const
 retrieves the time using IN parameters
bool isValid () const
 checks for the validity of the time
void setNull ()
 resets the time
int secondsSinceMidnight () const
int usec () const
 returns the microsecs
int msec () const
 returns the millisecs
int seconds () const
 returns the secs
int minutes () const
 returns the minutes
int hours () const
 returns the hours
int setMsec (int ms)
 sets the millisecs
int setUsec (int us)
 sets the microsecs
int parseFrom (const char *s)
 parses the time string passed and stores it It should of the format "hh:mm::ss"
Timeoperator++ ()
Timeoperator-- ()
Timeoperator+= (int seconds)
Timeoperator-= (int seconds)

Static Public Member Functions

static bool isValidTime (int hours, int mins, int secs)
 checks for the validity of the time specified

Friends

Time operator+ (const Time &t1, int seconds)
Time operator+ (int seconds, const Time &t1)
Time operator- (const Time &t1, int seconds)
int operator- (const Time &t1, const Time &t2)
int operator< (const Time &t1, const Time &t2)
int operator> (const Time &t1, const Time &t2)
int operator<= (const Time &t1, const Time &t2)
int operator>= (const Time &t1, const Time &t2)
int operator== (const Time &t1, const Time &t2)
int operator!= (const Time &t1, const Time &t2)


Detailed Description

Represents Time Data type.


Author:
Prabakaran Thirumalai

Definition at line 347 of file DataType.h.


Constructor & Destructor Documentation

Time::Time (  )  [inline]

Definition at line 349 of file DataType.h.

00349 {timeVal = 0;}

Time::Time ( int  hours,
int  mins,
int  secs,
int  usec = 0 
)

Overloaded constructor.

Parameters:
hours hours
mins mins
secs secs
usec usec

Definition at line 207 of file DataType.cxx.

References set().

00208     { set(hours,mins,secs, usec); }

Here is the call graph for this function:

Time::Time ( int  totalSecs  )  [inline]

Definition at line 358 of file DataType.h.

00358 : timeVal(totalSecs) {;}

Time::Time ( const Time d2  )  [inline]

Definition at line 359 of file DataType.h.

References timeVal.

00359 { timeVal = d2.timeVal; }


Member Function Documentation

int Time::get ( int &  hours,
int &  mins,
int &  secs 
) const

retrieves the time using IN parameters

Parameters:
hours hours
mins mins
secs secs

Definition at line 220 of file DataType.cxx.

Referenced by TimeStamp::getTime().

00220                                                     {
00221     if (timeVal < 0) return -1;
00222     int s = timeVal/10000;
00223     secs = s % 60;
00224     s /= 60;
00225     mins = s % 60;
00226     s /= 60;
00227     hours = s;
00228     return 0;
00229 }

Here is the caller graph for this function:

int Time::hours (  )  const

returns the hours

Definition at line 233 of file DataType.cxx.

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), TimeStamp::hours(), Java_csql_jdbc_JSqlStatement_getTime(), parseFrom(), and AllDataType::printVal().

00233 { return timeVal / (3600*10000); }

Here is the caller graph for this function:

bool Time::isValid (  )  const

checks for the validity of the time

Definition at line 248 of file DataType.cxx.

References MAX_VALID_SECONDS.

Referenced by TimeStamp::isValid().

00249     { return timeVal >= 0 && timeVal <= (10000*(MAX_VALID_SECONDS+1)-1); }

Here is the caller graph for this function:

bool Time::isValidTime ( int  hours,
int  mins,
int  secs 
) [static]

checks for the validity of the time specified

Definition at line 251 of file DataType.cxx.

Referenced by TimeStamp::parseFrom(), and parseFrom().

00251                                                     {
00252     return (hours >= 0 && hours < 24) &&
00253            (mins >= 0 && mins < 60) &&
00254            (secs >= 0 && secs < 60);
00255 }

Here is the caller graph for this function:

int Time::minutes (  )  const

returns the minutes

Definition at line 232 of file DataType.cxx.

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTime(), TimeStamp::minutes(), and AllDataType::printVal().

00232 { return (timeVal /(60*10000)) % 60; }

Here is the caller graph for this function:

int Time::msec (  )  const

returns the millisecs

Definition at line 234 of file DataType.cxx.

Referenced by TimeStamp::msec().

00234 { return (timeVal % 10000) / 10; }

Here is the caller graph for this function:

Time& Time::operator++ (  )  [inline]

Definition at line 421 of file DataType.h.

00421 { timeVal += 10000; return *this; }

Time& Time::operator+= ( int  seconds  )  [inline]

Definition at line 424 of file DataType.h.

00424 { timeVal += seconds*10000; return *this; }

Time& Time::operator-- (  )  [inline]

Definition at line 422 of file DataType.h.

00422 { timeVal -= 10000; return *this; }

Time& Time::operator-= ( int  seconds  )  [inline]

Definition at line 425 of file DataType.h.

00425 { timeVal -= seconds*10000; return *this; }

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

Definition at line 360 of file DataType.h.

References timeVal.

00360 { timeVal=d2.timeVal; return *this; }

int Time::parseFrom ( const char *  s  ) 

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

Definition at line 280 of file DataType.cxx.

References hours(), isValidTime(), and set().

Referenced by AllDataType::convertToTime(), and TimeStamp::parseTimeFrom().

00280                                  {
00281     int hours,mins,secs;
00282     int count;
00283     count = sscanf(s,"%d:%d:%d",&hours,&mins,&secs);
00284     if (count < 2) return -1;
00285     if (count == 2) secs = 0;
00286 
00287     if (!isValidTime(hours,mins,secs))
00288         return -1;
00289     return set(hours,mins,secs);
00290 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Time::seconds (  )  const

returns the secs

Definition at line 231 of file DataType.cxx.

Referenced by AllDataType::convertToString(), SqlOdbcStatement::execute(), Java_csql_jdbc_JSqlStatement_getTime(), AllDataType::printVal(), and TimeStamp::seconds().

00231 { return (timeVal/10000) % 60; }

Here is the caller graph for this function:

int Time::secondsSinceMidnight (  )  const [inline]

Definition at line 385 of file DataType.h.

Referenced by TimeStamp::secondsSinceMidnight().

00385 { return timeVal/10000;}

Here is the caller graph for this function:

int Time::set ( int  hours,
int  mins,
int  secs,
int  usec = 0 
)

sets the time with specified hours, mins, secs

Parameters:
hours hours
mins mins
secs secs
usec usec

Definition at line 210 of file DataType.cxx.

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

00210                                                      {
00211         if((hours | mins | secs | usec) < 0) { timeVal = -1; return -1; }
00212         if(hours >= 24 | mins >= 60 | secs >= 62)
00213                 { timeVal = -1; return -1; }
00214         timeVal = secs + mins * 60 + hours * 3600;
00215         timeVal *= 10000;
00216         if(usec) timeVal += usec/100;
00217         return 0;
00218 }

Here is the caller graph for this function:

int Time::setMsec ( int  ms  ) 

sets the millisecs

Definition at line 237 of file DataType.cxx.

Referenced by TimeStamp::setMsec().

00237                         {
00238         if(ms < 0 || ms >= 1000) return -1;
00239         timeVal = timeVal+(10*ms);
00240     return 0;
00241 }

Here is the caller graph for this function:

void Time::setNull (  )  [inline]

resets the time

Definition at line 383 of file DataType.h.

Referenced by TimeStamp::setNull().

00383 { timeVal = -1;}

Here is the caller graph for this function:

int Time::setUsec ( int  us  ) 

sets the microsecs

Definition at line 242 of file DataType.cxx.

Referenced by TimeStamp::setUsec().

00242                         {
00243         if(us < 0 || us >= 1000000) return -1;
00244         timeVal = timeVal +us/100;
00245     return 0;
00246 }

Here is the caller graph for this function:

int Time::usec (  )  const

returns the microsecs

Definition at line 235 of file DataType.cxx.

Referenced by TimeStamp::usec().

00235 { return (timeVal % 10000) * 100; }

Here is the caller graph for this function:


Friends And Related Function Documentation

int operator!= ( const Time t1,
const Time t2 
) [friend]

Definition at line 277 of file DataType.cxx.

00278     { return t1.timeVal != t2.timeVal; }

Time operator+ ( int  seconds,
const Time t1 
) [friend]

Definition at line 259 of file DataType.cxx.

00260     { return Time(t1.timeVal + seconds*10000); }

Time operator+ ( const Time t1,
int  seconds 
) [friend]

Definition at line 257 of file DataType.cxx.

00258     { return Time(t1.timeVal + seconds*10000); }

int operator- ( const Time t1,
const Time t2 
) [friend]

Definition at line 264 of file DataType.cxx.

00265     { return (t1.timeVal - t2.timeVal)/10000; }

Time operator- ( const Time t1,
int  seconds 
) [friend]

Definition at line 261 of file DataType.cxx.

00262     { return Time(t1.timeVal - seconds*10000); }

int operator< ( const Time t1,
const Time t2 
) [friend]

Definition at line 267 of file DataType.cxx.

00268     { return t1.timeVal < t2.timeVal; }

int operator<= ( const Time t1,
const Time t2 
) [friend]

Definition at line 271 of file DataType.cxx.

00272     { return t1.timeVal <= t2.timeVal; }

int operator== ( const Time t1,
const Time t2 
) [friend]

Definition at line 275 of file DataType.cxx.

00276     { return t1.timeVal == t2.timeVal; }

int operator> ( const Time t1,
const Time t2 
) [friend]

Definition at line 269 of file DataType.cxx.

00270     { return t1.timeVal > t2.timeVal; }

int operator>= ( const Time t1,
const Time t2 
) [friend]

Definition at line 273 of file DataType.cxx.

00274     { return t1.timeVal >= t2.timeVal; }


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