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

date.cc

00001 /*
00002 *  Name:      date.cc
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   UESQLC base SQL type date
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/date.hh>
00027 
00028 
00029 //
00030 //  C O N S T R U C T O R S
00031 //
00032 
00033 void uesqlc::TDate::set (const char* pkcVALUE)
00034 {
00035 
00036   using mpcl::text::TString;
00037   using std::atoi;
00038   using std::size_t;
00039   using std::time_t;
00040 
00041 // <FIXME comment="must check for invalid dates">
00042   setNull ( !pkcVALUE || !*pkcVALUE );
00043   if ( !isNull() )
00044   {
00045     int       iDay;
00046     int       iMonth;
00047     int       iYear;
00048     TString   yValue (pkcVALUE);
00049     size_t    zBegin = 0;
00050     size_t    zEnd   = 0;
00051 
00052     //
00053     //  First it cleans the source date, and then obtains the year.
00054     //
00055     yValue.suppressFirst ('\'');
00056     yValue.suppressLast ('\'');
00057     zEnd  = yValue.find ('-');
00058     iYear = atoi (yValue.substr (0, zEnd).c_str());
00059 
00060     //
00061     //  Second it obtains the month and the day
00062     //
00063     zBegin = zEnd + 1;
00064     zEnd   = yValue.find ('-', zBegin);
00065     iMonth = atoi (yValue.substr (zBegin, zEnd - zBegin).c_str());
00066     iDay   = atoi (yValue.substr (zEnd + 1).c_str());
00067     TLocalDate::set (iYear, iMonth, iDay);
00068   }
00069 // </FIXME>
00070 
00071 }  // set()

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