Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

time.cc

00001 /*
00002 *  Name:      time.cc
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   UESQLC base SQL type time
00005 *  Date:      $Date: 2003/10/06 13:21:35 $
00006 *  Revision:  $Revision: 1.2 $
00007 *
00008 *  Copyright (C) 2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #include <uesqlc/time.hh>
00027 
00028 
00029 //
00030 //  C O N S T R U C T O R S
00031 //
00032 
00033 void uesqlc::TTime::set (const char* pkcVALUE)
00034 {
00035 
00036   using mpcl::text::TString;
00037   using std::atoi;
00038   using std::size_t;
00039   using std::string;
00040   using std::time_t;
00041 
00042 // <FIXME comment="must check for invalid times">
00043   setNull ( !pkcVALUE || !*pkcVALUE );
00044   if ( !isNull() )
00045   {
00046     int       iSecond;
00047     int       iMinute;
00048     int       iHour;
00049     TString   yValue (pkcVALUE);
00050     size_t    zBegin = 0;
00051     size_t    zEnd   = 0;
00052 
00053     //
00054     //  First it cleans the source date, and then obtains the hour.
00055     //
00056     yValue.suppressFirst ('\'');
00057     yValue.suppressLast ('\'');
00058     zEnd = yValue.find (':');
00059     if ( zEnd == string::npos )
00060     {
00061       setNull (true);
00062       throw mpcl::TConstraintException ("invalid date", __FILE__, __LINE__);
00063     }
00064     else
00065     {
00066       //
00067       //  First it obtains the hour value. Second it obtains the minute and the
00068       //  second value.
00069       //
00070       iHour   = atoi (yValue.substr (0, zEnd).c_str());
00071       zBegin  = zEnd + 1;
00072       zEnd    = yValue.find (':', zBegin);
00073       if ( zEnd == string::npos )
00074       {
00075         setNull (true);
00076         throw mpcl::TConstraintException ("invalid date", __FILE__, __LINE__);
00077       }
00078       else
00079       {
00080         iMinute = atoi (yValue.substr (zBegin, zEnd - zBegin).c_str());
00081         iSecond = atoi (yValue.substr (zEnd + 1).c_str());
00082         TLocalDate::set (1970, 1, 1, iHour, iMinute, iSecond);
00083       }
00084     }
00085   }
00086 // </FIXME>
00087   
00088 }  // set()

Generated on Mon Oct 13 02:40:10 2003 for UESQLC by doxygen1.2.18