NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CTimeSpan Class Reference

Search Toolkit Book for CTimeSpan

CTimeSpan. More...

#include <corelib/ncbitime.hpp>

Public Types

enum  ESmartStringFlags {
  fSS_Year = (1 << 0) , fSS_Month = (1 << 1) , fSS_Day = (1 << 2) , fSS_Hour = (1 << 3) ,
  fSS_Minute = (1 << 4) , fSS_Second = (1 << 5) , fSS_Millisecond = (1 << 6) , fSS_Microsecond = (1 << 7) ,
  fSS_Nanosecond = (1 << 8) , fSS_Precision1 = (1 << 9) , fSS_Precision2 = (1 << 10) , fSS_Precision3 = (1 << 11) ,
  fSS_Precision4 = (1 << 12) , fSS_Precision5 = (1 << 13) , fSS_Precision6 = (1 << 14) , fSS_Precision7 = (1 << 15) ,
  fSS_Smart = (1 << 16) , fSS_PrecisionMask = 0x1FFFF , fSS_Round = (1 << 20) , fSS_Trunc = (1 << 21) ,
  fSS_NoSkipZero = (1 << 22) , fSS_SkipZero = (1 << 23) , fSS_Short = (1 << 24) , fSS_Full = (1 << 25) ,
  fSS_Default = 0
}
 AsSmartString() conversion flags. More...
 
enum  ESmartStringPrecision {
  eSSP_Year = fSS_Year , eSSP_Month = fSS_Month , eSSP_Day = fSS_Day , eSSP_Hour = fSS_Hour ,
  eSSP_Minute = fSS_Minute , eSSP_Second = fSS_Second , eSSP_Millisecond = fSS_Millisecond , eSSP_Microsecond = fSS_Microsecond ,
  eSSP_Nanosecond = fSS_Nanosecond , eSSP_Precision1 = fSS_Precision1 , eSSP_Precision2 = fSS_Precision2 , eSSP_Precision3 = fSS_Precision3 ,
  eSSP_Precision4 = fSS_Precision4 , eSSP_Precision5 = fSS_Precision5 , eSSP_Precision6 = fSS_Precision6 , eSSP_Precision7 = fSS_Precision7 ,
  eSSP_Smart = fSS_Smart
}
 Precision for span "smart" string. More...
 
enum  ESmartStringZeroMode { eSSZ_NoSkipZero = fSS_NoSkipZero , eSSZ_SkipZero = fSS_SkipZero }
 Which format use to output zero time span parts. More...
 
typedef unsigned int TSmartStringFlags
 Binary OR of "ESmartStringFlags". More...
 

Public Member Functions

 CTimeSpan (void)
 Default constructor. More...
 
 CTimeSpan (long days, long hours, long minutes, long seconds, long nanoseconds=0)
 Constructor. More...
 
 CTimeSpan (long seconds, long nanoseconds=0)
 Constructor. More...
 
 CTimeSpan (double seconds)
 Constructor. More...
 
 CTimeSpan (const string &str, const CTimeFormat &fmt=kEmptyStr)
 Explicit conversion constructor for string representation of time span. More...
 
 CTimeSpan (const CTimeSpan &t)
 Copy constructor. More...
 
CTimeSpanoperator= (const CTimeSpan &t)
 Assignment operator. More...
 
CTimeSpanoperator= (const string &str)
 Assignment operator. More...
 
CTimeSpanClear (void)
 Make the time span "empty",. More...
 
ESign GetSign (void) const
 Get sign of time span. More...
 
string AsString (const CTimeFormat &fmt=kEmptyStr) const
 Transform time span to string. More...
 
 operator string (void) const
 Return span time as string using the format returned by GetFormat(). More...
 
string AsSmartString (ESmartStringPrecision precision, ERound rounding, ESmartStringZeroMode zero_mode=eSSZ_SkipZero) const
 Transform time span to "smart" string. More...
 
string AsSmartString (TSmartStringFlags flags=0) const
 Transform time span to "smart" string. More...
 
CTimeSpanAssignFromSmartString (const string &str)
 Assign value to time span object from string representation of time in formats produced by AsSmartString(). More...
 
long GetCompleteDays (void) const
 Get number of complete days. More...
 
long GetCompleteHours (void) const
 Get number of complete hours. More...
 
long GetCompleteMinutes (void) const
 Get number of complete minutes. More...
 
long GetCompleteSeconds (void) const
 Get number of complete seconds. More...
 
long GetNanoSecondsAfterSecond (void) const
 Get number of nanoseconds. More...
 
double GetAsDouble (void) const
 Return time span as number of seconds. More...
 
bool IsEmpty (void) const
 Return TRUE is an object keep zero time span. More...
 
void Set (long seconds, long nanoseconds=0)
 Set time span in seconds and nanoseconds. More...
 
void Set (double seconds)
 Set time span from number of seconds (fractional value). More...
 
CTimeSpanoperator+= (const CTimeSpan &t)
 
CTimeSpan operator+ (const CTimeSpan &t) const
 
CTimeSpanoperator-= (const CTimeSpan &t)
 Operator to subtract time span. More...
 
CTimeSpan operator- (const CTimeSpan &t) const
 Operator to subtract time span. More...
 
CTimeSpan operator- (void) const
 Unary operator "-" (minus) to change time span sign. More...
 
void Invert (void)
 Invert time span. Changes time span sign. More...
 
bool operator== (const CTimeSpan &t) const
 Operator to test equality of time span. More...
 
bool operator!= (const CTimeSpan &t) const
 Operator to test in-equality of time span. More...
 
bool operator> (const CTimeSpan &t) const
 Operator to test if time span is greater. More...
 
bool operator< (const CTimeSpan &t) const
 Operator to test if time span is less. More...
 
bool operator>= (const CTimeSpan &t) const
 Operator to test if time span is greater or equal. More...
 
bool operator<= (const CTimeSpan &t) const
 Operator to test if time span is less or equal. More...
 

Static Public Member Functions

static void SetFormat (const CTimeFormat &format)
 Set the current time span format. More...
 
static CTimeFormat GetFormat (void)
 Get the current time span format. More...
 

Private Member Functions

int x_Hour (void) const
 Get hour. More...
 
int x_Minute (void) const
 Get minute. More...
 
int x_Second (void) const
 Get second. More...
 
void x_Init (const string &str, const CTimeFormat &fmt)
 Helper method to set time value from string "str" using format "fmt". More...
 
void x_Normalize (void)
 Helper method to normalize stored time value. More...
 
string x_AsSmartString_Smart_Big (TSmartStringFlags flags) const
 Helpers for AsSmartString() More...
 
string x_AsSmartString_Smart_Small (TSmartStringFlags flags) const
 
string x_AsSmartString_Precision (TSmartStringFlags flags) const
 

Private Attributes

long m_Sec
 Seconds part of the time span. More...
 
long m_NanoSec
 Nanoseconds after the second. More...
 

Detailed Description

CTimeSpan.

Defines a class to represents a relative time span. Time span can be both positive and negative and hold value in range [LONG_MIN - LONG_MAX] seconds (a little more than 68 years in each direction).

Throw exception of type CTimeException on errors.

Examples
/home/coremake/doxygen/cxx/include/util/scheduler.hpp.

Definition at line 1312 of file ncbitime.hpp.


The documentation for this class was generated from the following files:
Modified on Mon May 20 05:06:06 2024 by modify_doxy.py rev. 669887