FirteX-高性能全文索引和检索平台

API Documentation


首页 | 名字空间列表 | 类继承关系 | 组合类型列表 | $(BL\录(B | 文件列表 | 名字空间成员 | 组合类型成员 | 文件成员

DateTime.h

浏览该文件的文档。
00001 //
00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 
00003 // All rights reserved.
00004 // This file is part of FirteX (www.firtex.org)
00005 //
00006 // Use of the FirteX is subject to the terms of the software license set forth in 
00007 // the LICENSE file included with this software, and also available at
00008 // http://www.firtex.org/license.html
00009 //
00010 // Author       : 郭瑞杰(GuoRuijie)
00011 // Email        : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com
00012 // Created      : 2006/5/19
00013 //
00014 #ifndef _DATETIME_H
00015 #define _DATETIME_H
00016 
00017 #if _MSC_VER > 1000
00018 #pragma once
00019 #endif // _MSC_VER > 1000
00020 
00021 #include "StdHeader.h"
00022 #include <ostream>
00023 #include <istream>
00024 #include <string>
00025 
00026 using namespace std;
00027 
00028 namespace firtex
00029 {
00030         namespace utility
00031         {
00032                 class CDateTimeSpan
00033                 {
00034                 public:
00035                         CDateTimeSpan() throw();
00036                         CDateTimeSpan( int64_t time ) throw();
00037                         CDateTimeSpan( int nDays, int nHours, int nMins, int nSecs ) throw();
00038 
00039                         int64_t getDays() const throw();
00040                         int64_t getTotalHours() const throw();
00041                         int64_t getHours() const throw();
00042                         int64_t getTotalMinutes() const throw();
00043                         int64_t getMinutes() const throw();
00044                         int64_t getTotalSeconds() const throw();
00045                         int64_t getSeconds() const throw();
00046 
00047                         int64_t getSpan() const throw();
00048 
00049                         CDateTimeSpan operator+( CDateTimeSpan span ) const throw();
00050                         CDateTimeSpan operator-( CDateTimeSpan span ) const throw();
00051                         CDateTimeSpan& operator+=( CDateTimeSpan span ) throw();
00052                         CDateTimeSpan& operator-=( CDateTimeSpan span ) throw();
00053                         bool operator==( CDateTimeSpan span ) const throw();
00054                         bool operator!=( CDateTimeSpan span ) const throw();
00055                         bool operator<( CDateTimeSpan span ) const throw();
00056                         bool operator>( CDateTimeSpan span ) const throw();
00057                         bool operator<=( CDateTimeSpan span ) const throw();
00058                         bool operator>=( CDateTimeSpan span ) const throw();
00059 
00060                 private:
00061                         int64_t m_timeSpan;
00062                 };
00063 
00064 
00065                 class CDateTime
00066                 {
00067                 public:
00068                         static CDateTime  getCurrentTime() throw();
00069 
00070                         CDateTime() throw();
00071                         CDateTime( int64_t time ) throw();
00072                         CDateTime( int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec,int nDST = -1 );                      
00073 
00074                 public:
00075                         CDateTime& operator=( int64_t time ) throw();
00076 
00077                         CDateTime& operator+=( CDateTimeSpan span ) throw();
00078                         CDateTime& operator-=( CDateTimeSpan span ) throw();
00079 
00080                         CDateTimeSpan operator-( CDateTime time ) const throw();
00081                         CDateTime operator-( CDateTimeSpan span ) const throw();
00082                         CDateTime operator+( CDateTimeSpan span ) const throw();
00083 
00084                         bool operator==( CDateTime time ) const throw();
00085                         bool operator!=( CDateTime time ) const throw();
00086                         bool operator<( CDateTime time ) const throw();
00087                         bool operator>( CDateTime time ) const throw();
00088                         bool operator<=( CDateTime time ) const throw();
00089                         bool operator>=( CDateTime time ) const throw();
00090 
00091                         int64_t         getTime() const throw();                struct tm*      getGmtTm( struct tm* ptm = NULL ) const throw();
00092 
00093 #ifdef WIN32    
00094                         struct tm*      getLocalTm( struct tm* ptm = NULL ) const throw();
00095 
00096 
00097                         int getYear() const throw();
00098                         int getMonth() const throw();
00099                         int getDay() const throw();
00100                         int getHour() const throw();
00101                         int getMinute() const throw();
00102                         int getSecond() const throw();
00103                         int getDayOfWeek() const throw();
00104 
00105 #endif
00106                         tstring format(const tstring& sformat = "%Y/%m/%d %H:%M:%S")const;
00107                 
00108                 public:
00109                         static tstring  format(int64_t t,const tstring& sformat = "%Y/%m/%d %H:%M:%S");
00110 
00111                         // Stream I/O operators
00112                         friend ostream& operator<<(ostream& os, const CDateTime& d);
00113 
00114                         friend istream& operator>>(istream& is, CDateTime& d);
00115 
00116                         static int isleap(int y)
00117                         {return y%4 == 0 && y%100 != 0 || y%400 == 0;}
00118                 
00119                 private:
00120                         int64_t m_time;                 
00121                 };
00122                 const int maxTimeBufferSize = 128;
00124                 //Inline functions      
00125 
00126         }
00127 }
00128 
00129 #endif

http://www.firtex.org http://www.sourceforge.net/projects/firtex