⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncbitime.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 3 页
字号:
    CStopWatch(void);    /// Start the timer.    void Start(void);    /// Return time elapsed time since last Start() call.    /// Result is underfined if Start() wasn't previously called.    double Elapsed(void) const;protected:    /// Get current time mark.    static double GetTimeMark();private:    double m_Start;  ///< Start time value.};/* @} *///=============================================================================////  Extern////=============================================================================// Add (subtract if negative) to the time (see CTime::AddXXX)NCBI_XNCBI_EXPORTextern CTime AddYear       (const CTime& t, int  years       = 1);NCBI_XNCBI_EXPORTextern CTime AddMonth      (const CTime& t, int  months      = 1);NCBI_XNCBI_EXPORTextern CTime AddDay        (const CTime& t, int  days        = 1);NCBI_XNCBI_EXPORTextern CTime AddHour       (const CTime& t, int  hours       = 1);NCBI_XNCBI_EXPORTextern CTime AddMinute     (const CTime& t, int  minutes     = 1);NCBI_XNCBI_EXPORTextern CTime AddSecond     (const CTime& t, int  seconds     = 1);NCBI_XNCBI_EXPORTextern CTime AddNanoSecond (const CTime& t, long nanoseconds = 1);// Add/subtract days (see CTime::operator +/-)NCBI_XNCBI_EXPORTextern CTime operator + (int days, const CTime& t);NCBI_XNCBI_EXPORTextern CTime operator + (const CTime& t, int days);NCBI_XNCBI_EXPORTextern CTime operator - (const CTime& t, int days);// Difference in days (see CTime::operator)NCBI_XNCBI_EXPORTextern int   operator - (const CTime& t1, const CTime& t2);// Get current time (in local or GMT format)NCBI_XNCBI_EXPORTextern CTime CurrentTime(    CTime::ETimeZone          tz  = CTime::eLocal,     CTime::ETimeZonePrecision tzp = CTime::eTZPrecisionDefault    );// Truncate the time to days (see CTime::Truncate)NCBI_XNCBI_EXPORT extern CTime Truncate(const CTime& t);//=============================================================================////  Inline////=============================================================================// CTimeinline int CTime::Year(void) const { return m_Year; }inline int CTime::Month(void) const { return m_Month; }inline int CTime::Day(void) const { return m_Day; }inline int CTime::Hour(void) const { return m_Hour; }inline int CTime::Minute(void) const { return m_Minute; }inline int CTime::Second(void) const { return m_Second; }inline long CTime::NanoSecond(void) const { return (long) m_NanoSecond; }inline CTime& CTime::AddYear(int years, EDaylight adl){    return AddMonth(years * 12, adl);}inlineCTime& CTime::SetTimeT(const time_t& t) { return x_SetTime(&t); }inlineCTime& CTime::SetCurrent(void) { return x_SetTime(); }inline CTime& CTime::operator += (const int days) { return AddDay(days); }inline CTime& CTime::operator -= (const int days) { return AddDay(-days); }inline CTime& CTime::operator ++ (void) { return AddDay( 1); }inline CTime& CTime::operator -- (void) { return AddDay(-1); }inline CTime::operator string(void) const { return AsString(); }inline CTime CTime::operator ++ (int){    CTime t = *this;    AddDay(1);    return t;}inline CTime CTime::operator -- (int){    CTime t = *this;    AddDay(-1);    return t;}inline CTime& CTime::operator = (const string& str){    x_Init(str, GetFormat());    return *this;}inline CTime& CTime::operator = (const CTime& t){    if ( &t == this )        return *this;    m_Year           = t.m_Year;    m_Month          = t.m_Month;    m_Day            = t.m_Day;    m_Hour           = t.m_Hour;    m_Minute         = t.m_Minute;    m_Second         = t.m_Second;    m_NanoSecond     = t.m_NanoSecond;    m_Tz             = t.m_Tz;    m_TzPrecision    = t.m_TzPrecision;    m_AdjustTimeDiff = t.m_AdjustTimeDiff;    return *this;}inline bool CTime::operator != (const CTime& t) const{    return !(*this == t);}inline bool CTime::operator >= (const CTime& t) const{    return !(*this < t);}inlinebool CTime::operator <= (const CTime& t) const{    return !(*this > t);}inlineCTime& CTime::AddHour(int hours, EDaylight use_daylight){    return x_AddHour(hours, use_daylight, true);}inline bool CTime::IsEmpty() const{    return        !Day()   &&  !Month()   &&  !Year()  &&        !Hour()  &&  !Minute()  &&  !Second()  &&  !NanoSecond();}inline double CTime::DiffDay(const CTime& t) const{    return DiffSecond(t) / 60.0 / 60.0 / 24.0;}inline double CTime::DiffHour(const CTime& t) const{    return DiffSecond(t) / 60.0 / 60.0;}inline double CTime::DiffMinute(const CTime& t) const{    return DiffSecond(t) / 60.0;}inline double CTime::DiffNanoSecond(const CTime& t) const{    long dNanoSec = NanoSecond() - t.NanoSecond();    return (double) DiffSecond(t) * kNanoSecondsPerSecond + dNanoSec;}inline bool CTime::IsLocalTime(void) const { return m_Tz == eLocal; } inline bool CTime::IsGmtTime(void) const { return m_Tz == eGmt; }inline CTime::ETimeZone CTime::GetTimeZoneFormat(void) const{    return m_Tz;}inline CTime::ETimeZonePrecision CTime::GetTimeZonePrecision(void) const{    return m_TzPrecision;}inline CTime::ETimeZone CTime::SetTimeZoneFormat(ETimeZone val){    ETimeZone tmp = m_Tz;    m_Tz = val;    return tmp;}inline CTime::ETimeZonePrecision CTime::SetTimeZonePrecision(ETimeZonePrecision val){    ETimeZonePrecision tmp = m_TzPrecision;    m_TzPrecision = val;    return tmp;}inline int CTime::TimeZoneDiff(void) const{    return GetLocalTime().DiffSecond(GetGmtTime());}inline CTime CTime::GetLocalTime(void) const{    if ( IsLocalTime() )        return *this;    CTime t(*this);    return t.ToLocalTime();}inline CTime CTime::GetGmtTime(void) const{    if ( IsGmtTime() )        return *this;    CTime t(*this);    return t.ToGmtTime();}inlineCTime& CTime::ToLocalTime(void){    ToTime(eLocal);    return *this;}inlineCTime& CTime::ToGmtTime(void){    ToTime(eGmt);    return *this;}inline bool CTime::x_NeedAdjustTime(void) const{    return GetTimeZoneFormat() == eLocal  &&  GetTimeZonePrecision() != eNone;}// CStopWatchinlineCStopWatch::CStopWatch(void)    : m_Start(0){}inlinevoid CStopWatch::Start(){    m_Start = GetTimeMark();}inlinedouble CStopWatch::Elapsed() const{    return GetTimeMark() - m_Start;}END_NCBI_SCOPE/* * =========================================================================== * $Log: ncbitime.hpp,v $ * Revision 1000.5  2004/04/21 14:34:55  gouriano * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.33 * * Revision 1.33  2004/04/07 19:07:29  lavr * Document CStopWatch in a little more details * * Revision 1.32  2004/03/24 15:52:50  ivanov * Added new format symbol support 'z' (local time in format GMT{+|-}HHMM). * Added second parameter to AsString() method that specify an output * timezone. * * Revision 1.31  2004/03/10 19:56:38  gorelenk * Added NCBI_XNCBI_EXPORT prefix for functions AddYear, AddMonth, AddDay, * AddHour, AddMinute, AddSecond, AddNanoSecond and operators: * CTime operator + and CTime operator - . * * Revision 1.30  2004/01/26 18:07:22  siyan * Fixed errors in documentation on GetTimeT() * * Revision 1.29  2003/11/25 20:03:32  ivanov * Fixed misspelled eTZPrecisionDefault * * Revision 1.28  2003/11/25 19:53:33  ivanov * Renamed eDefault to eTZPrecisionDefault. * Added setters for various components of time -- Set*(). * Added YearWeekNumber(), MonthWeekNumber(). * Reimplemented AddYear() as AddMonth(years*12). * * Revision 1.27  2003/11/21 20:04:41  ivanov * + DaysInMonth() * * Revision 1.26  2003/11/18 11:58:24  siyan * Changed so @addtogroup does not cross namespace boundary * * Revision 1.25  2003/10/03 18:26:48  ivanov * Added month and day of week names conversion functions * * Revision 1.24  2003/09/11 13:26:13  siyan * Documentation changes * * Revision 1.23  2003/07/15 19:34:28  vakatov * Comment typo fix * * Revision 1.22  2003/04/16 20:28:26  ivanov * Added class CStopWatch * * Revision 1.21  2003/04/14 19:41:32  ivanov * Rollback to R1.19 -- accidental commit * * Revision 1.19  2003/04/01 19:18:43  siyan * Added doxygen support * * Revision 1.18  2003/02/10 22:36:55  ucko * Make string- and time_t-based constructors explicit, to avoid weird surprises. * * Revision 1.17  2002/12/18 22:53:21  dicuccio * Added export specifier for building DLLs in windows.  Added global list of * all such specifiers in mswin_exports.hpp, included through ncbistl.hpp * * Revision 1.16  2002/10/17 16:55:01  ivanov * Added new time format symbols - 'b' and 'B' (month abbreviated and full name) * * Revision 1.15  2002/07/23 19:53:34  lebedev * NCBI_OS_MAC: Note about Daylight flag handling added * * Revision 1.14  2002/07/15 18:17:52  gouriano * renamed CNcbiException and its descendents * * Revision 1.13  2002/07/11 14:17:56  gouriano * exceptions replaced by CNcbiException-type ones * * Revision 1.12  2002/05/13 13:56:30  ivanov * Added MT-Safe support * * Revision 1.11  2002/04/11 20:39:20  ivanov * CVS log moved to end of the file * * Revision 1.10  2001/07/06 15:11:30  ivanov * Added support DataBase-time's -- GetTimeDBI(), GetTimeDBU() *                                  SetTimeDBI(), SetTimeDBU() * * Revision 1.9  2001/07/04 19:41:07  vakatov * Get rid of an extra semicolon * * Revision 1.8  2001/06/12 16:56:36  vakatov * Added comments for the time constituents access methods * * Revision 1.7  2001/05/29 20:12:58  ivanov * Changed type of return value in NanoSecond(). * * Revision 1.6  2001/05/29 16:14:34  ivanov * Return to nanosecond-revision. Corrected mistake of the work with local * time on Linux. Polish and improvement source code. * Renamed AsTimeT() -> GetTimerT(). * * Revision 1.5  2001/04/30 22:01:29  lavr * Rollback to pre-nanosecond-revision due to necessity to use * configure to figure out names of global variables governing time zones * * Revision 1.4  2001/04/29 03:06:10  lavr * #include <time.h>" moved from .cpp to ncbitime.hpp * * Revision 1.3  2001/04/27 20:42:29  ivanov * Support for Local and UTC time added. * Support for work with nanoseconds added. * * Revision 1.2  2000/11/21 18:15:29  butanaev * Fixed bug in operator ++/-- (int) * * Revision 1.1  2000/11/20 22:17:42  vakatov * Added NCBI date/time class CTime ("ncbitime.[ch]pp") and * its test suite ("test/test_ncbitime.cpp") * * =========================================================================== */#endif /* CORELIB__NCBITIME__HPP */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -