src/corelib/ncbitime.cpp File Reference

#include <ncbi_pch.hpp>
#include <corelib/ncbitime.hpp>
#include <corelib/ncbimtx.hpp>
#include <corelib/ncbithr.hpp>
#include <corelib/ncbi_safe_static.hpp>
#include <corelib/ncbi_limits.h>
#include <corelib/error_codes.hpp>
#include <stdlib.h>

Include dependency graph for ncbitime.cpp:

Go to the source code of this file.

Classes

struct  SSmartStringItem

Defines

#define TimeZone()   timezone
#define Daylight()   daylight
#define NCBI_USE_ERRCODE_X   Corelib_Util
#define CHECK_RANGE(value, what, min, max)
#define CHECK_RANGE_YEAR(value)   CHECK_RANGE(value, "year", 1583, kMax_Int)
#define CHECK_RANGE_MONTH(value)   CHECK_RANGE(value, "month", 1, 12)
#define CHECK_RANGE_DAY(value)   CHECK_RANGE(value, "day", 1, 31)
#define CHECK_RANGE_HOUR(value)   CHECK_RANGE(value, "hour", 0, 23)
#define CHECK_RANGE_MIN(value)   CHECK_RANGE(value, "minute", 0, 59)
#define CHECK_RANGE_SEC(value)   CHECK_RANGE(value, "second", 0, 61)
#define CHECK_RANGE_NSEC(value)

Functions

 DEFINE_STATIC_FAST_MUTEX (s_TimeMutex)
 DEFINE_STATIC_FAST_MUTEX (s_TimeAdjustMutex)
 DEFINE_STATIC_FAST_MUTEX (s_FastLocalTimeMutex)
static void s_TlsFormatCleanup (CTimeFormat *fmt, void *)
static unsigned s_Date2Number (const CTime &date)
static CTime s_Number2Date (unsigned num, const CTime &t)
static void s_Offset (long *value, Int8 offset, long bound, int *major)
static void s_AddZeroPadInt (string &str, long value, SIZE_TYPE len=2)
static void s_GetTimeT (time_t &timer, long &ns)
string s_SpecialValueName (CTimeout::EType type)
int s_TimeoutCompareHash (const CTimeout &t)
CTime GetFastLocalTime (void)
 Quick and dirty getter of local time.
void TuneupFastLocalTime (void)

Variables

static CStaticTls< CTimeFormats_TlsFormatTime
static CStaticTls< CTimeFormats_TlsFormatSpan
static CStaticTls< CTimeFormats_TlsFormatStopWatch
static CSafeStaticPtr< CFastLocalTimes_FastLocalTime
static int s_DaysInMonth [12]
static const char * kMonthAbbr [12]
static const char * kMonthFull [12]
static const char * kWeekdayAbbr [7]
static const char * kWeekdayFull [7]
static const char * kDefaultFormatTime = "M/D/Y h:m:s"
static const char * kDefaultFormatSpan = "-S.n"
static const char * kDefaultFormatStopWatch = "-S.n"
static const char * kFormatSymbolsTime = "yYMbBDdhHmsSzZwWlrpP"
static const char * kFormatSymbolsSpan = "-dhHmMsSnN"
const char kFormatEscapeSymbol = '$'


Define Documentation

#define CHECK_RANGE value,
what,
min,
max   ) 
 

Value:

if ( value < min  ||  value > max ) {  \
        NCBI_THROW(CTimeException, eArgument, \
                   "CTime: " what " value '" + \
                   NStr::Int8ToString(value) + "' is out of range"); \
    }

Definition at line 205 of file ncbitime.cpp.

#define CHECK_RANGE_DAY value   )     CHECK_RANGE(value, "day", 1, 31)
 

Definition at line 214 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetDay(), and CTime::SetTimeTM().

#define CHECK_RANGE_HOUR value   )     CHECK_RANGE(value, "hour", 0, 23)
 

Definition at line 215 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetHour(), and CTime::SetTimeTM().

#define CHECK_RANGE_MIN value   )     CHECK_RANGE(value, "minute", 0, 59)
 

Definition at line 216 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetMinute(), and CTime::SetTimeTM().

#define CHECK_RANGE_MONTH value   )     CHECK_RANGE(value, "month", 1, 12)
 

Definition at line 213 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetMonth(), and CTime::SetTimeTM().

#define CHECK_RANGE_NSEC value   ) 
 

Value:

CHECK_RANGE(value, "nanosecond", 0, \
                                             kNanoSecondsPerSecond - 1)

Definition at line 218 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetMicroSecond(), CTime::SetMilliSecond(), CTime::SetNanoSecond(), and CTime::x_SetTime().

#define CHECK_RANGE_SEC value   )     CHECK_RANGE(value, "second", 0, 61)
 

Definition at line 217 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetSecond(), and CTime::SetTimeTM().

#define CHECK_RANGE_YEAR value   )     CHECK_RANGE(value, "year", 1583, kMax_Int)
 

Definition at line 212 of file ncbitime.cpp.

Referenced by CTime::CTime(), CTime::SetTimeTM(), and CTime::SetYear().

 
#define Daylight  )     daylight
 

Definition at line 52 of file ncbitime.cpp.

Referenced by CFastLocalTime::CFastLocalTime(), CFastLocalTime::GetLocalTime(), CFastLocalTime::GetLocalTimezone(), CTime::GetTimeT(), and CFastLocalTime::x_Tuneup().

#define NCBI_USE_ERRCODE_X   Corelib_Util
 

Definition at line 60 of file ncbitime.cpp.

 
#define TimeZone  )     timezone
 

Definition at line 51 of file ncbitime.cpp.

Referenced by CTime::AsString(), CFastLocalTime::CFastLocalTime(), CFastLocalTime::GetLocalTime(), CFastLocalTime::GetLocalTimezone(), CTime::GetTimeT(), and CFastLocalTime::x_Tuneup().


Function Documentation

DEFINE_STATIC_FAST_MUTEX s_FastLocalTimeMutex   ) 
 

DEFINE_STATIC_FAST_MUTEX s_TimeAdjustMutex   ) 
 

DEFINE_STATIC_FAST_MUTEX s_TimeMutex   ) 
 

CTime GetFastLocalTime void   ) 
 

Quick and dirty getter of local time.

Use global object of CFastLocalTime class to obtain time. See CFastLocalTime for details.

Definition at line 2963 of file ncbitime.cpp.

References s_FastLocalTime.

Referenced by BOOST_AUTO_TEST_CASE(), CDiagContext::GetNextHitID(), and SDiagMessage::GetTime().

static void s_AddZeroPadInt string &  str,
long  value,
SIZE_TYPE  len = 2
[static]
 

Definition at line 958 of file ncbitime.cpp.

References NStr::IntToString().

static unsigned s_Date2Number const CTime date  )  [static]
 

Definition at line 126 of file ncbitime.cpp.

References CTime::IsEmptyDate(), and NCBI_THROW.

Referenced by CTime::AddDay(), CTime::DiffWholeDays(), CTime::GetTimeDBI(), CTime::GetTimeDBU(), and CTime::YearDayNumber().

static void s_GetTimeT time_t &  timer,
long &  ns
[static]
 

Definition at line 1287 of file ncbitime.cpp.

References kMicroSecondsPerSecond, kMilliSecondsPerSecond, kNanoSecondsPerSecond, and NCBI_THROW.

Referenced by CFastLocalTime::GetLocalTime(), CFastLocalTime::GetLocalTimezone(), CFastLocalTime::Tuneup(), and CTime::x_SetTime().

static CTime s_Number2Date unsigned  num,
const CTime t
[static]
 

Definition at line 153 of file ncbitime.cpp.

References CTime::GetTimeZone(), CTime::GetTimeZonePrecision(), CTime::Hour(), CTime::Minute(), CTime::NanoSecond(), and CTime::Second().

Referenced by CTime::AddDay().

static void s_Offset long *  value,
Int8  offset,
long  bound,
int *  major
[static]
 

Definition at line 188 of file ncbitime.cpp.

Referenced by CTime::AddMinute(), CTime::AddMonth(), CTime::AddNanoSecond(), CTime::AddSecond(), and CTime::x_AddHour().

string s_SpecialValueName CTimeout::EType  type  ) 
 

Definition at line 2407 of file ncbitime.cpp.

References CTimeout::eDefault, CTimeout::eInfinite, CTimeout::eZero, and kEmptyStr.

Referenced by CTimeout::Get(), CTimeout::GetAsDouble(), CTimeout::GetAsMilliSeconds(), and CTimeout::GetAsTimeSpan().

int s_TimeoutCompareHash const CTimeout t  )  [inline]
 

Definition at line 2582 of file ncbitime.cpp.

References CTimeout::IsDefault(), and CTimeout::IsInfinite().

Referenced by CTimeout::operator<(), CTimeout::operator<=(), CTimeout::operator==(), CTimeout::operator>(), and CTimeout::operator>=().

static void s_TlsFormatCleanup CTimeFormat fmt,
void * 
[static]
 

Definition at line 76 of file ncbitime.cpp.

Referenced by CStopWatch::SetFormat(), CTimeSpan::SetFormat(), and CTime::SetFormat().

void TuneupFastLocalTime void   ) 
 

Definition at line 2969 of file ncbitime.cpp.

References s_FastLocalTime.


Variable Documentation

const char* kDefaultFormatSpan = "-S.n" [static]
 

Definition at line 113 of file ncbitime.cpp.

Referenced by CTimeSpan::GetFormat().

const char* kDefaultFormatStopWatch = "-S.n" [static]
 

Definition at line 114 of file ncbitime.cpp.

Referenced by CStopWatch::GetFormat().

const char* kDefaultFormatTime = "M/D/Y h:m:s" [static]
 

Definition at line 112 of file ncbitime.cpp.

Referenced by CTime::GetFormat().

const char kFormatEscapeSymbol = '$'
 

Definition at line 123 of file ncbitime.cpp.

const char* kFormatSymbolsSpan = "-dhHmMsSnN" [static]
 

Definition at line 120 of file ncbitime.cpp.

const char* kFormatSymbolsTime = "yYMbBDdhHmsSzZwWlrpP" [static]
 

Definition at line 119 of file ncbitime.cpp.

const char* kMonthAbbr[12] [static]
 

Initial value:

 {
    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
}

Definition at line 93 of file ncbitime.cpp.

Referenced by CTime::MonthNameToNum(), and CTime::MonthNumToName().

const char* kMonthFull[12] [static]
 

Initial value:

 {
    "January", "February", "March", "April", "May", "June",
    "July", "August", "September", "October", "November", "December"
}

Definition at line 97 of file ncbitime.cpp.

Referenced by CTime::MonthNameToNum(), and CTime::MonthNumToName().

const char* kWeekdayAbbr[7] [static]
 

Initial value:

 {
    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
}

Definition at line 103 of file ncbitime.cpp.

Referenced by CTime::DayOfWeekNameToNum(), and CTime::DayOfWeekNumToName().

const char* kWeekdayFull[7] [static]
 

Initial value:

 {
    "Sunday", "Monday", "Tuesday", "Wednesday",
    "Thursday", "Friday", "Saturday"
}

Definition at line 106 of file ncbitime.cpp.

Referenced by CTime::DayOfWeekNameToNum(), and CTime::DayOfWeekNumToName().

int s_DaysInMonth[12] [static]
 

Initial value:

 {
    31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
}

Definition at line 88 of file ncbitime.cpp.

Referenced by CTime::DaysInMonth(), and CTime::IsValid().

CSafeStaticPtr<CFastLocalTime> s_FastLocalTime [static]
 

Definition at line 82 of file ncbitime.cpp.

Referenced by GetFastLocalTime(), and TuneupFastLocalTime().

CStaticTls<CTimeFormat> s_TlsFormatSpan [static]
 

Definition at line 73 of file ncbitime.cpp.

Referenced by CTimeSpan::GetFormat(), and CTimeSpan::SetFormat().

CStaticTls<CTimeFormat> s_TlsFormatStopWatch [static]
 

Definition at line 74 of file ncbitime.cpp.

Referenced by CStopWatch::GetFormat(), and CStopWatch::SetFormat().

CStaticTls<CTimeFormat> s_TlsFormatTime [static]
 

Definition at line 72 of file ncbitime.cpp.

Referenced by CTime::GetFormat(), and CTime::SetFormat().


Generated on Mon Dec 7 07:36:52 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:21:45 2009 by modify_doxy.py rev. 173732