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

CTBodbcTime.cxx

Go to the documentation of this file.
00001 //
00002 // $Id: CTBodbcTime.cxx,v 1.4 2000/02/29 12:50:10 mueller Exp $
00003 //
00004 /*----------------------------------------------------------------------------*/
00005 /* C Tool Box: Designed and implemented by:                                   */
00006 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00007 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00008 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00009 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00010 /*------------------------------------------+---------------------------------*/
00011 
00012 #include <time.h>
00013 
00014 #include "CTB.hxx"
00015 #include "CTBtime.hxx"
00016 #include "CTBprintf.hxx"
00017 #include "CTBodbc.hxx"
00018 #include "CTBodbcTime.hxx"
00019 
00025 //------------------------------------------+-----------------------------------
00027 
00028 CTBodbcTime::CTBodbcTime()
00029 {
00030   m_time.year     = 0;
00031   m_time.month    = 0;
00032   m_time.day      = 0;
00033   m_time.hour     = 0;
00034   m_time.minute   = 0;
00035   m_time.second   = 0;
00036   m_time.fraction = 0;
00037 }
00038 
00039 //------------------------------------------+-----------------------------------
00041 
00042 int CTBodbcTime::ToUTime() const
00043 {
00044   return CTBtime::ymdhms2ui(m_time.year, m_time.month,m_time.day,
00045                             m_time.hour,m_time.minute,m_time.second);
00046 }
00047 
00048 //------------------------------------------+-----------------------------------
00050 
00051 void CTBodbcTime::FromUTime(int i_utime)
00052 {
00053   time_t      i_time_val = i_utime;
00054   struct tm*  ps_time = localtime(&i_time_val);
00055 
00056   m_time.year     = ps_time->tm_year + 1900;
00057   m_time.month    = ps_time->tm_mon  + 1;
00058   m_time.day      = ps_time->tm_mday;
00059   m_time.hour     = ps_time->tm_hour;
00060   m_time.minute   = ps_time->tm_min;
00061   m_time.second   = ps_time->tm_sec;
00062   m_time.fraction = 0;
00063 
00064   return;
00065 }
00066 
00067 //------------------------------------------+-----------------------------------
00069 
00070 void CTBodbcTime::ToStream(ostream& os) const
00071 {
00072   os << CTBprintf(m_time.year,"d0",4) << "-"
00073      << CTBprintf(m_time.month,"d0",2) << "-"
00074      << CTBprintf(m_time.day,"d0",2) << " "
00075      << CTBprintf(m_time.hour,"d0",2) << ":"
00076      << CTBprintf(m_time.minute,"d0",2) << ":"
00077      << CTBprintf(m_time.second,"d0",2);
00078   if (m_time.fraction != 0) {
00079     os << "." << CTBprintf(m_time.fraction,"d0",9);
00080   }
00081   return;
00082 }
00083 
00084 //------------------------------------------+-----------------------------------
00085 
00086 #if (defined(CTB__OutLine) || defined(CTBodbcTime__OutLine))
00087 #define inline
00088 #include "CTBodbcTime.icc"
00089 #undef  inline
00090 #endif

Generated at Fri Oct 24 18:16:03 2003 for CTBodbc by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001