CLinearTimeAbsolute Class Reference

#include <timeutil.h>


Public Member Functions

 CLinearTimeAbsolute (void)
 CLinearTimeAbsolute (const CLinearTimeAbsolute &ltaOrigin, const CLinearTimeDelta &ltdOffset)
 CLinearTimeAbsolute (const CLinearTimeAbsolute &lta)
void operator= (const CLinearTimeAbsolute &lta)
void operator+= (const CLinearTimeDelta &ltdOffset)
void operator-= (const CLinearTimeDelta &ltdOffset)
void GetUTC (void)
void GetLocal (void)
void ReturnUniqueString (char *buffer)
char * ReturnDateString (int nFracDigits=0)
bool ReturnFields (FIELDEDTIME *arg_tStruct)
INT64 ReturnSeconds (void)
char * ReturnSecondsString (int nFracDigits=0)
INT64 Return100ns (void)
void SetSeconds (INT64 arg_tSeconds)
bool SetSecondsString (char *arg_szSeconds)
bool SetFields (FIELDEDTIME *arg_tStruct)
bool SetString (const char *arg_tBuffer)
void Set100ns (INT64 arg_t100ns)
void UTC2Local (void)
void Local2UTC (void)

Private Attributes

INT64 m_tAbsolute

Static Private Attributes

static int m_nCount = 0
static char m_Buffer [204]

Friends

class CLinearTimeDelta
bool operator< (const CLinearTimeAbsolute &lta, const CLinearTimeAbsolute &ltb)
bool operator> (const CLinearTimeAbsolute &lta, const CLinearTimeAbsolute &ltb)
bool operator== (const CLinearTimeAbsolute &lta, const CLinearTimeAbsolute &ltb)
bool operator<= (const CLinearTimeAbsolute &lta, const CLinearTimeAbsolute &ltb)
CLinearTimeAbsolute operator+ (const CLinearTimeAbsolute &lta, const CLinearTimeDelta &ltd)
CLinearTimeAbsolute operator- (const CLinearTimeAbsolute &lta, const CLinearTimeDelta &ltd)
CLinearTimeDelta operator- (const CLinearTimeAbsolute &lta, const CLinearTimeAbsolute &ltb)


Detailed Description

Definition at line 32 of file timeutil.h.


Constructor & Destructor Documentation

CLinearTimeAbsolute::CLinearTimeAbsolute ( void   ) 

Definition at line 682 of file timeutil.cpp.

References m_tAbsolute.

00683 {
00684     m_tAbsolute = 0;
00685 }

CLinearTimeAbsolute::CLinearTimeAbsolute ( const CLinearTimeAbsolute ltaOrigin,
const CLinearTimeDelta ltdOffset 
)

Definition at line 461 of file timeutil.cpp.

References m_tAbsolute, and CLinearTimeDelta::m_tDelta.

00462 {
00463     m_tAbsolute = ltaOrigin.m_tAbsolute + ltdOffset.m_tDelta;
00464 }

CLinearTimeAbsolute::CLinearTimeAbsolute ( const CLinearTimeAbsolute lta  ) 

Definition at line 677 of file timeutil.cpp.

References m_tAbsolute.

00678 {
00679     m_tAbsolute = lta.m_tAbsolute;
00680 }


Member Function Documentation

void CLinearTimeAbsolute::GetLocal ( void   ) 

Definition at line 1327 of file timeutil.cpp.

References GetUTCLinearTime(), m_tAbsolute, and UTC2Local().

Referenced by announce_connect(), check_events(), check_mail_expiration(), CLogFile::CLogFile(), connect_player(), create_obj(), do_report(), CLogFile::Flush(), FUNCTION(), GetProcessorUsage(), mail_match(), mail_return(), main(), page_return(), send_mail(), set_modified(), start_log(), and CLogFile::StartLogging().

01328 {
01329     GetUTCLinearTime(&m_tAbsolute);
01330     UTC2Local();
01331 }

void CLinearTimeAbsolute::GetUTC ( void   ) 

Definition at line 1322 of file timeutil.cpp.

References GetUTCLinearTime(), and m_tAbsolute.

Referenced by cache_init(), CallBack_NotifySemaphoreDrainOrAll(), CallBack_NotifySemaphoreFirstOrQuiet(), check_connect(), check_idle(), dispatch_CacheTick(), dispatch_CheckEvents(), dispatch_DatabaseDump(), dispatch_FreeListReconstruction(), dispatch_IdleCheck(), do_command(), do_ps(), do_queue(), do_wait(), dump_users(), fetch_connect(), fetch_idle(), FUNCTION(), init_timer(), initializesock(), list_db_stats(), list_options(), main(), report_timecheck(), SeedRandomNumberGenerator(), SetupGlobalThrottle(), SetupThrottle(), shovechars(), shutdownsock(), sighandler(), Task_ProcessCommand(), Task_RunQueueEntry(), ThrottleAttributeNames(), ThrottleMail(), and ThrottlePlayerCreate().

01323 {
01324     GetUTCLinearTime(&m_tAbsolute);
01325 }

void CLinearTimeAbsolute::Local2UTC ( void   ) 

Definition at line 2400 of file timeutil.cpp.

References m_tAbsolute, and QueryLocalOffsetAtUTC().

Referenced by FUNCTION().

02401 {
02402     bool bDST1, bDST2;
02403     CLinearTimeDelta ltdOffset1 = QueryLocalOffsetAtUTC(*this, &bDST1);
02404     CLinearTimeAbsolute ltaUTC2 = *this - ltdOffset1;
02405     CLinearTimeDelta ltdOffset2 = QueryLocalOffsetAtUTC(ltaUTC2, &bDST2);
02406 
02407     CLinearTimeAbsolute ltaLocalGuess = ltaUTC2 + ltdOffset2;
02408     if (ltaLocalGuess == *this)
02409     {
02410         // We found an offset, UTC, local time combination that
02411         // works.
02412         //
02413         m_tAbsolute = ltaUTC2.m_tAbsolute;
02414     }
02415     else
02416     {
02417         CLinearTimeAbsolute ltaUTC1 = *this - ltdOffset2;
02418         m_tAbsolute = ltaUTC1.m_tAbsolute;
02419     }
02420 }

void CLinearTimeAbsolute::operator+= ( const CLinearTimeDelta ltdOffset  ) 

Definition at line 1235 of file timeutil.cpp.

References m_tAbsolute, and CLinearTimeDelta::m_tDelta.

01236 {
01237     m_tAbsolute += ltd.m_tDelta;
01238 }

void CLinearTimeAbsolute::operator-= ( const CLinearTimeDelta ltdOffset  ) 

Definition at line 1230 of file timeutil.cpp.

References m_tAbsolute, and CLinearTimeDelta::m_tDelta.

01231 {
01232     m_tAbsolute -= ltd.m_tDelta;
01233 }

void CLinearTimeAbsolute::operator= ( const CLinearTimeAbsolute lta  ) 

Definition at line 1202 of file timeutil.cpp.

References m_tAbsolute.

01203 {
01204     m_tAbsolute = lta.m_tAbsolute;
01205 }

INT64 CLinearTimeAbsolute::Return100ns ( void   ) 

Definition at line 772 of file timeutil.cpp.

References m_tAbsolute.

Referenced by ConvertAllFieldsToLinearTime(), and SeedRandomNumberGenerator().

00773 {
00774     return m_tAbsolute;
00775 }

char * CLinearTimeAbsolute::ReturnDateString ( int  nFracDigits = 0  ) 

Definition at line 1272 of file timeutil.cpp.

References FIELDEDTIME::iDayOfMonth, FIELDEDTIME::iDayOfWeek, FIELDEDTIME::iHour, FIELDEDTIME::iMicrosecond, FIELDEDTIME::iMillisecond, FIELDEDTIME::iMinute, FIELDEDTIME::iMonth, FIELDEDTIME::iNanosecond, FIELDEDTIME::iSecond, FIELDEDTIME::iYear, LinearTimeToFieldedTime(), m_Buffer, and m_tAbsolute.

Referenced by announce_connect(), connect_player(), create_obj(), dump_info(), FUNCTION(), send_mail(), and set_modified().

01273 {
01274     FIELDEDTIME ft;
01275     if (LinearTimeToFieldedTime(m_tAbsolute, &ft))
01276     {
01277         // Sanitize Precision Request.
01278         //
01279         const int maxFracDigits = 7;
01280         const int minFracDigits = 0;
01281         if (nFracDigits < minFracDigits)
01282         {
01283             nFracDigits = minFracDigits;
01284         }
01285         else if (maxFracDigits < nFracDigits)
01286         {
01287             nFracDigits = maxFracDigits;
01288         }
01289 
01290         char buffer[11];
01291         buffer[0] = '\0';
01292         if (  0 < nFracDigits
01293            && (  ft.iMillisecond != 0
01294               || ft.iMicrosecond != 0
01295               || ft.iNanosecond != 0))
01296         {
01297             sprintf(buffer, ".%03d%03d%03d", ft.iMillisecond, ft.iMicrosecond,
01298                 ft.iNanosecond);
01299 
01300             // Remove trailing zeros.
01301             //
01302             char *p = (buffer + 1) + (nFracDigits - 1);
01303             while (*p == '0')
01304             {
01305                 p--;
01306             }
01307             p++;
01308             *p = '\0';
01309         }
01310         sprintf(m_Buffer, "%s %s %02d %02d:%02d:%02d%s %04d",
01311             DayOfWeekString[ft.iDayOfWeek], monthtab[ft.iMonth-1],
01312             ft.iDayOfMonth, ft.iHour, ft.iMinute, ft.iSecond, buffer,
01313             ft.iYear);
01314     }
01315     else
01316     {
01317         m_Buffer[0] = '\0';
01318     }
01319     return m_Buffer;
01320 }

bool CLinearTimeAbsolute::ReturnFields ( FIELDEDTIME arg_tStruct  ) 

Definition at line 1157 of file timeutil.cpp.

References LinearTimeToFieldedTime(), and m_tAbsolute.

Referenced by check_events(), ConvertAllFieldsToLinearTime(), FUNCTION(), mail_return(), page_return(), QueryLocalOffsetAt_Internal(), start_log(), and TIME_Initialize().

01158 {
01159     return LinearTimeToFieldedTime(m_tAbsolute, arg_tStruct);
01160 }

INT64 CLinearTimeAbsolute::ReturnSeconds ( void   ) 

Definition at line 788 of file timeutil.cpp.

References EPOCH_OFFSET, i64FloorDivision(), and m_tAbsolute.

Referenced by dump_restart_db(), put_ConnectionInfoFields(), and QueryLocalOffsetAt_Internal().

00789 {
00790     // INT64 is in hundreds of nanoseconds.
00791     // And the Epoch is 0:00 1/1/1601 instead of 0:00 1/1/1970
00792     //
00793     return i64FloorDivision(m_tAbsolute - EPOCH_OFFSET, FACTOR_100NS_PER_SECOND);
00794 }

char * CLinearTimeAbsolute::ReturnSecondsString ( int  nFracDigits = 0  ) 

Definition at line 671 of file timeutil.cpp.

References ConvertToSecondsString(), EPOCH_OFFSET, m_Buffer, and m_tAbsolute.

Referenced by FUNCTION().

00672 {
00673     ConvertToSecondsString(m_Buffer, m_tAbsolute - EPOCH_OFFSET, nFracDigits);
00674     return m_Buffer;
00675 }

void CLinearTimeAbsolute::ReturnUniqueString ( char *  buffer  ) 

Definition at line 1258 of file timeutil.cpp.

References FIELDEDTIME::iDayOfMonth, FIELDEDTIME::iHour, FIELDEDTIME::iMinute, FIELDEDTIME::iMonth, FIELDEDTIME::iSecond, FIELDEDTIME::iYear, LinearTimeToFieldedTime(), m_nCount, and m_tAbsolute.

Referenced by MakeLogName().

01259 {
01260     FIELDEDTIME ft;
01261     if (LinearTimeToFieldedTime(m_tAbsolute, &ft))
01262     {
01263         sprintf(buffer, "%04d%02d%02d-%02d%02d%02d", ft.iYear, ft.iMonth,
01264                 ft.iDayOfMonth, ft.iHour, ft.iMinute, ft.iSecond);
01265     }
01266     else
01267     {
01268         sprintf(buffer, "%03d", m_nCount++);
01269     }
01270 }

void CLinearTimeAbsolute::Set100ns ( INT64  arg_t100ns  ) 

Definition at line 767 of file timeutil.cpp.

References m_tAbsolute.

Referenced by ConvertAllFieldsToLinearTime(), create_obj(), and initialize_objects().

00768 {
00769     m_tAbsolute = arg_t100ns;
00770 }

bool CLinearTimeAbsolute::SetFields ( FIELDEDTIME arg_tStruct  ) 

Definition at line 1240 of file timeutil.cpp.

References FieldedTimeToLinearTime(), and m_tAbsolute.

Referenced by ConvertAllFieldsToLinearTime(), QueryLocalOffsetAt_Internal(), test_time_t(), and YearType().

01241 {
01242     m_tAbsolute = 0;
01243     return FieldedTimeToLinearTime(arg_tStruct, &m_tAbsolute);
01244 }

void CLinearTimeAbsolute::SetSeconds ( INT64  arg_tSeconds  ) 

Definition at line 777 of file timeutil.cpp.

References EPOCH_OFFSET, and m_tAbsolute.

Referenced by fetch_logouttime(), load_restart_db(), QueryLocalOffsetAt_Internal(), test_time_t(), and CScheduler::WhenNext().

00778 {
00779     m_tAbsolute = arg_tSeconds;
00780     m_tAbsolute *= FACTOR_100NS_PER_SECOND;
00781 
00782     // Epoch difference between (00:00:00 UTC, January 1, 1970) and
00783     // (00:00:00 UTC, January 1, 1601).
00784     //
00785     m_tAbsolute += EPOCH_OFFSET;
00786 }

bool CLinearTimeAbsolute::SetSecondsString ( char *  arg_szSeconds  ) 

Definition at line 1392 of file timeutil.cpp.

References EARLIEST_VALID_DATE, EPOCH_OFFSET, LATEST_VALID_DATE, m_tAbsolute, and ParseFractionalSecondsString().

Referenced by do_wait(), fetch_logouttime(), and FUNCTION().

01393 {
01394     INT64 t;
01395     const INT64 tEarliest = EARLIEST_VALID_DATE;
01396     const INT64 tLatest   = LATEST_VALID_DATE;
01397     ParseFractionalSecondsString(t, arg_szSeconds);
01398     t += EPOCH_OFFSET;
01399     if (  tEarliest <= t
01400        && t <= tLatest)
01401     {
01402         m_tAbsolute = t;
01403         return true;
01404     }
01405     return false;
01406 }

bool CLinearTimeAbsolute::SetString ( const char *  arg_tBuffer  ) 

Definition at line 1162 of file timeutil.cpp.

References do_convtime(), FieldedTimeToLinearTime(), and m_tAbsolute.

Referenced by check_mail_expiration(), do_report(), FUNCTION(), and mail_match().

01163 {
01164     FIELDEDTIME ft;
01165     if (do_convtime(arg_tBuffer, &ft))
01166     {
01167         if (FieldedTimeToLinearTime(&ft, &m_tAbsolute))
01168         {
01169             return true;
01170         }
01171     }
01172     m_tAbsolute = 0;
01173     return false;
01174 }

void CLinearTimeAbsolute::UTC2Local ( void   ) 

Definition at line 2393 of file timeutil.cpp.

References m_tAbsolute, CLinearTimeDelta::m_tDelta, and QueryLocalOffsetAtUTC().

Referenced by FUNCTION(), and GetLocal().

02394 {
02395     bool bDST;
02396     CLinearTimeDelta ltd = QueryLocalOffsetAtUTC(*this, &bDST);
02397     m_tAbsolute += ltd.m_tDelta;
02398 }


Friends And Related Function Documentation

friend class CLinearTimeDelta [friend]

Definition at line 34 of file timeutil.h.

CLinearTimeAbsolute operator+ ( const CLinearTimeAbsolute lta,
const CLinearTimeDelta ltd 
) [friend]

Definition at line 1195 of file timeutil.cpp.

01196 {
01197     CLinearTimeAbsolute lta;
01198     lta.m_tAbsolute = ltaA.m_tAbsolute + ltdB.m_tDelta;
01199     return lta;
01200 }

CLinearTimeDelta operator- ( const CLinearTimeAbsolute lta,
const CLinearTimeAbsolute ltb 
) [friend]

Definition at line 1181 of file timeutil.cpp.

01182 {
01183     CLinearTimeDelta ltd;
01184     ltd.m_tDelta = ltaA.m_tAbsolute - ltaB.m_tAbsolute;
01185     return ltd;
01186 }

CLinearTimeAbsolute operator- ( const CLinearTimeAbsolute lta,
const CLinearTimeDelta ltd 
) [friend]

Definition at line 454 of file timeutil.cpp.

00455 {
00456     CLinearTimeAbsolute t;
00457     t.m_tAbsolute = lta.m_tAbsolute - ltd.m_tDelta;
00458     return t;
00459 }

bool operator< ( const CLinearTimeAbsolute lta,
const CLinearTimeAbsolute ltb 
) [friend]

Definition at line 419 of file timeutil.cpp.

00420 {
00421     return lta.m_tAbsolute < ltb.m_tAbsolute;
00422 }

bool operator<= ( const CLinearTimeAbsolute lta,
const CLinearTimeAbsolute ltb 
) [friend]

Definition at line 449 of file timeutil.cpp.

00450 {
00451     return lta.m_tAbsolute <= ltb.m_tAbsolute;
00452 }

bool operator== ( const CLinearTimeAbsolute lta,
const CLinearTimeAbsolute ltb 
) [friend]

Definition at line 429 of file timeutil.cpp.

00430 {
00431     return lta.m_tAbsolute == ltb.m_tAbsolute;
00432 }

bool operator> ( const CLinearTimeAbsolute lta,
const CLinearTimeAbsolute ltb 
) [friend]

Definition at line 424 of file timeutil.cpp.

00425 {
00426     return lta.m_tAbsolute > ltb.m_tAbsolute;
00427 }


Field Documentation

char CLinearTimeAbsolute::m_Buffer [static, private]

Definition at line 46 of file timeutil.h.

Referenced by ReturnDateString(), and ReturnSecondsString().

int CLinearTimeAbsolute::m_nCount = 0 [static, private]

Definition at line 45 of file timeutil.h.

Referenced by ReturnUniqueString().

INT64 CLinearTimeAbsolute::m_tAbsolute [private]

Definition at line 44 of file timeutil.h.

Referenced by CLinearTimeAbsolute(), CLinearTimeDelta::CLinearTimeDelta(), GetLocal(), GetUTC(), Local2UTC(), operator+(), operator+=(), operator-(), operator-=(), operator<(), operator<=(), operator=(), operator==(), operator>(), Return100ns(), ReturnDateString(), ReturnFields(), ReturnSeconds(), ReturnSecondsString(), ReturnUniqueString(), Set100ns(), SetFields(), SetSeconds(), SetSecondsString(), SetString(), and UTC2Local().


The documentation for this class was generated from the following files:
Generated on Mon May 28 04:40:24 2007 for MUX by  doxygen 1.4.7