Main Page | Namespace List | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

timeutils.h

Go to the documentation of this file.
00001 
00002 // Common Text Transformation Library
00003 // Copyright (C) 1997-2006 by Igor Kholodov. 
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the
00017 // Free Software Foundation, Inc.,
00018 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 //
00020 // mailto:cttl@users.sourceforge.net
00021 // http://sourceforge.net/projects/cttl/
00023 
00029 // timeutils.h
00030 
00031 #ifndef _CTTL_TIMEUTILS_H_INCLUDED_
00032 #define _CTTL_TIMEUTILS_H_INCLUDED_
00033 
00034 /* Use the following in your code to suppress microsoft deprecation warnings:
00035 #ifdef _WIN32
00036     // suppress windows platform deprecation warnings:
00037 #   ifndef _CRT_SECURE_NO_DEPRECATE
00038 #   define _CRT_SECURE_NO_DEPRECATE
00039 #   endif // _CRT_SECURE_NO_DEPRECATE
00040 #endif // _WIN32
00041 */
00042 
00043 #include <ctime>
00044 #include <string>
00045 
00046 namespace cttl {
00047 
00049 inline
00050 time_t current_time()
00051 {
00052     return time( NULL );
00053 }
00054 
00056 inline
00057 CTTL_STD_STRING time2string( time_t time_ )
00058 {
00059     CTTL_STD_CHAR* ptime = reinterpret_cast< CTTL_STD_CHAR* >( ctime( &time_ ) );  // get rid of the trailing \n
00060     return CTTL_STD_STRING( ptime, strlen( reinterpret_cast< char const* >( ptime ) ) - 1 );
00061 }
00062 
00063 }//namespace cttl
00064 
00065 
00066 #endif // _CTTL_TIMEUTILS_H_INCLUDED_

Generated on Thu Nov 2 17:43:39 2006 for CTTL Utility Classes and Functions by  doxygen 1.3.9.1