Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cTimeDouble Class Reference

#include <cTimeDouble.h>

Public Member Functions

 cTimeDouble (const cTimeDouble &dt)
 
 cTimeDouble (const double dTime=k_nZero)
 
 cTimeDouble (const TIMESEC_t nTimeSec)
 
 cTimeDouble (const cTimeFile &ft)
 
 cTimeDouble (const cTimeUnits &rTu)
 
void InitTime (double dTime=k_nZero)
 
void InitTimeNow ()
 
bool isTimeValid () const
 
double get_Double () const
 
double get_Days () const
 
 operator double (void) const
 
void operator= (const cTimeDouble &date)
 
void operator= (const GChar_t *pszDateTime)
 
cTimeDouble operator+ (int i)
 
cTimeDouble operator- (int i)
 
cTimeDouble operator+ (const cTimeDouble &dt)
 
cTimeDouble operator- (const cTimeDouble &dt)
 
cTimeDoubleoperator+= (int idays)
 
cTimeDoubleoperator-= (int idays)
 
cTimeDoubleoperator+= (const cTimeDouble &dt)
 
cTimeDoubleoperator-= (const cTimeDouble &dt)
 
cTimeDoubleoperator++ ()
 
cTimeDoubleoperator++ (int)
 
cTimeDoubleoperator-- ()
 
cTimeDoubleoperator-- (int)
 
cTimeFile GetAsFileTime () const
 
bool GetTimeUnits (OUT cTimeUnits &rTu, TZ_TYPE nTimeZoneOffset) const
 
TIMEDOW_TYPE get_DayOfWeek () const
 MFC GetDayOfWeek is +1. More...
 
unsigned GetDate () const
 < Numeric date of date object More...
 
double get_DaysTil () const
 
double get_DaysAge () const
 
HRESULT SetTimeStr (const GChar_t *pszDateTime, TZ_TYPE nTimeZoneOffset=TZ_UTC)
 
cString GetTimeFormStr (const GChar_t *pszFormat=nullptr, TZ_TYPE nTimeZoneOffset=TZ_LOCAL) const
 
cString GetTimeFormStr (TIME_FORMAT_TYPE eFormat, TZ_TYPE nTimeZoneOffset=TZ_LOCAL) const
 

Static Public Member Functions

static cTimeDouble __stdcall EncodeSeconds (double s)
 
static cTimeDouble __stdcall EncodeTime (short h, short m, short s, short ms=0)
 
static cTimeDouble __stdcall EncodeDate (short year=0, short month=0, short day=0)
 
static cTimeDouble __stdcall GetTimeFromSec (TIMESEC_t nTimeSec)
 
static cTimeDouble __stdcall GetTimeFromFile (const cTimeFile &ft)
 
static cTimeDouble __stdcall GetTimeFromStr (const GChar_t *pszDateTime, TZ_TYPE nTimeZoneOffset)
 
static bool IsTimeValid (double dTime)
 
static cTimeDouble __stdcall GetTimeNow ()
 
static cTimeDouble __stdcall Date ()
 
static cTimeDouble __stdcall Time ()
 
static cString __stdcall GetTimeSpanStr (double dDays, TIMEUNIT_TYPE eUnitHigh=TIMEUNIT_Day, int iUnitsDesired=2, bool bShortText=false)
 

Static Public Attributes

static const int k_nDaysDiffTimeInt = 25569
 days difference from cTimeDouble (1899) to cTimeInt (1970) bases // similar to linux SECS_1601_TO_1970 ? More...
 
static const double k_nY2K = 36526.0
 The static value for y2k = January 1, 2000 in UTC/GMT. More...
 
static const double k_nY10 = 3650.0
 The first 10 years are sometimes reserved to act as offsets. More...
 
static const int k_nZero = 0
 double cant be used for in-class initializer More...
 

Protected Member Functions

bool InitTimeUnits (const cTimeUnits &rTu)
 
void DecodeDate (cTimeUnits &rTu) const
 

Protected Attributes

double m_dateTime
 DATE = days since (midnight, 30 December 1899 GMT), fraction = time of day. More...
 

Friends

class cTimeDoubleTests
 
bool operator< (const cTimeDouble &dt1, const cTimeDouble &dt2)
 
bool operator<= (const cTimeDouble &dt1, const cTimeDouble &dt2)
 
bool operator> (const cTimeDouble &dt1, const cTimeDouble &dt2)
 
bool operator>= (const cTimeDouble &dt1, const cTimeDouble &dt2)
 
bool operator== (const cTimeDouble &dt1, const cTimeDouble &dt2)
 
bool operator!= (const cTimeDouble &dt1, const cTimeDouble &dt2)
 

Detailed Description

same as DATE, COleDateTime same as _WIN32 VariantTimeToSystemTime, same as DATE, COleDateTime Absolute 64 bit double days since (1899/12/30 midnight GMT). double 1.0 = 1 day NOT the same as REFTIME which is (double) seconds.

Constructor & Destructor Documentation

◆ cTimeDouble() [1/5]

Gray::cTimeDouble::cTimeDouble ( const cTimeDouble dt)
inline

◆ cTimeDouble() [2/5]

Gray::cTimeDouble::cTimeDouble ( const double  dTime = k_nZero)
inline

◆ cTimeDouble() [3/5]

Gray::cTimeDouble::cTimeDouble ( const TIMESEC_t  nTimeSec)
inline

◆ cTimeDouble() [4/5]

Gray::cTimeDouble::cTimeDouble ( const cTimeFile ft)
inline

◆ cTimeDouble() [5/5]

Gray::cTimeDouble::cTimeDouble ( const cTimeUnits rTu)
inline

like SystemTimeToVariantTime but it ASSUMES GMT m_dateTime = 1 = whole days since 1900

Member Function Documentation

◆ Date()

cTimeDouble Gray::cTimeDouble::Date ( )
static

Get just whole days portion for now.

◆ DecodeDate()

void Gray::cTimeDouble::DecodeDate ( cTimeUnits rTu) const
protected

◆ EncodeDate()

cTimeDouble GRAYCALL Gray::cTimeDouble::EncodeDate ( short  year = 0,
short  month = 0,
short  day = 0 
)
static

Encode GMT Date as days since (1899/12/30 midnight GMT) or (1900/1/1 0:0:0 GMT) same as SystemTimeToVariantTime() but more accurate for mSec

◆ EncodeSeconds()

cTimeDouble GRAYCALL Gray::cTimeDouble::EncodeSeconds ( double  s)
static

Encode GMT Time

◆ EncodeTime()

cTimeDouble GRAYCALL Gray::cTimeDouble::EncodeTime ( short  h,
short  m,
short  s,
short  ms = 0 
)
static

Encode GMT Time Same as MFC COleDateTime::EncodeTime

◆ get_DayOfWeek()

TIMEDOW_TYPE Gray::cTimeDouble::get_DayOfWeek ( void  ) const

MFC GetDayOfWeek is +1.

Sunday is 0, TIMEDOW_TYPE MFC does (sun=1) but we don't

◆ get_Days()

double Gray::cTimeDouble::get_Days ( ) const
inline

Get total days since epoch.

◆ get_DaysAge()

double Gray::cTimeDouble::get_DaysAge ( ) const
inline

How old is this? (in days) current time - this time.

  • = this is in the past.
  • = this is in the future.

◆ get_DaysTil()

double Gray::cTimeDouble::get_DaysTil ( ) const
inline

diff in days

  • = this is in the past.
  • = this is in the future.

◆ get_Double()

double Gray::cTimeDouble::get_Double ( ) const
inline

Arbitrary units. same as days.

◆ GetAsFileTime()

cTimeFile Gray::cTimeDouble::GetAsFileTime ( ) const

convert double time to file system time cTimeFile = 64-bit 100-nanosec since January 1, 1601 GMT

◆ GetDate()

unsigned Gray::cTimeDouble::GetDate ( ) const
inline

< Numeric date of date object

Get Total days as an integer.

◆ GetTimeFormStr() [1/2]

cString Gray::cTimeDouble::GetTimeFormStr ( const GChar_t pszFormat = nullptr,
TZ_TYPE  nTimeZoneOffset = TZ_LOCAL 
) const

Get the time as a string formatted using "C" strftime() MFC just calls this "Format"

◆ GetTimeFormStr() [2/2]

cString Gray::cTimeDouble::GetTimeFormStr ( TIME_FORMAT_TYPE  eFormat,
TZ_TYPE  nTimeZoneOffset = TZ_LOCAL 
) const
inline

◆ GetTimeFromFile()

cTimeDouble GRAYCALL Gray::cTimeDouble::GetTimeFromFile ( const cTimeFile ft)
static

cTimeFile = 64-bit 100-nanosec since January 1, 1601 GMT double = days since (midnight, 30 December 1899 GMT)

◆ GetTimeFromSec()

cTimeDouble Gray::cTimeDouble::GetTimeFromSec ( TIMESEC_t  nTimeSec)
static

convert TIMESEC_t (seconds) to double (days) Opposite of cTimeInt::GetTimeFromDays()

◆ GetTimeFromStr()

static cTimeDouble __stdcall Gray::cTimeDouble::GetTimeFromStr ( const GChar_t pszDateTime,
TZ_TYPE  nTimeZoneOffset 
)
inlinestatic

◆ GetTimeNow()

cTimeDouble GRAYCALL Gray::cTimeDouble::GetTimeNow ( )
static

cTimeFile = 64-bit 100-nanosec since January 1, 1601 GMT/UTC

◆ GetTimeSpanStr()

cString GRAYCALL Gray::cTimeDouble::GetTimeSpanStr ( double  dDays,
TIMEUNIT_TYPE  eUnitHigh = TIMEUNIT_Day,
int  iUnitsDesired = 2,
bool  bShortText = false 
)
static

Describe a delta/span of time from days to milliseconds. iUnitHigh = 0 = days.

Todo:
MERGE THIS WITH cTimeUnits::GetTimeSpanStr version?!

◆ GetTimeUnits()

bool Gray::cTimeDouble::GetTimeUnits ( OUT cTimeUnits rTu,
TZ_TYPE  nTimeZoneOffset 
) const

Convert to cTimeUnits as TZ_UTC = TZ_GMT = NOT localized system time. Number of days since Dec. 30, 1899 VariantTimeToSystemTime

Returns
month = 1-12 day =

◆ InitTime()

void Gray::cTimeDouble::InitTime ( double  dTime = k_nZero)
inline

< dTime = 0 = clear to invalid time.

◆ InitTimeNow()

void Gray::cTimeDouble::InitTimeNow ( )

◆ InitTimeUnits()

bool Gray::cTimeDouble::InitTimeUnits ( const cTimeUnits rTu)
protected

◆ isTimeValid()

bool Gray::cTimeDouble::isTimeValid ( ) const
inline

◆ IsTimeValid()

static bool Gray::cTimeDouble::IsTimeValid ( double  dTime)
inlinestatic

◆ operator double()

Gray::cTimeDouble::operator double ( void  ) const
inline

Get total days since epoch.

◆ operator+() [1/2]

cTimeDouble Gray::cTimeDouble::operator+ ( const cTimeDouble dt)
inline

◆ operator+() [2/2]

cTimeDouble Gray::cTimeDouble::operator+ ( int  i)
inline

Add days.

◆ operator++() [1/2]

cTimeDouble& Gray::cTimeDouble::operator++ ( )
inline

◆ operator++() [2/2]

cTimeDouble& Gray::cTimeDouble::operator++ ( int  )
inline

◆ operator+=() [1/2]

cTimeDouble& Gray::cTimeDouble::operator+= ( const cTimeDouble dt)
inline

◆ operator+=() [2/2]

cTimeDouble& Gray::cTimeDouble::operator+= ( int  idays)
inline

Add days.

Parameters
idaysdays

◆ operator-() [1/2]

cTimeDouble Gray::cTimeDouble::operator- ( const cTimeDouble dt)
inline

◆ operator-() [2/2]

cTimeDouble Gray::cTimeDouble::operator- ( int  i)
inline

Subtract days.

◆ operator--() [1/2]

cTimeDouble& Gray::cTimeDouble::operator-- ( )
inline

◆ operator--() [2/2]

cTimeDouble& Gray::cTimeDouble::operator-- ( int  )
inline

◆ operator-=() [1/2]

cTimeDouble& Gray::cTimeDouble::operator-= ( const cTimeDouble dt)
inline

◆ operator-=() [2/2]

cTimeDouble& Gray::cTimeDouble::operator-= ( int  idays)
inline

Subtract days.

Parameters
idaysdays

◆ operator=() [1/2]

void Gray::cTimeDouble::operator= ( const cTimeDouble date)
inline

◆ operator=() [2/2]

void Gray::cTimeDouble::operator= ( const GChar_t pszDateTime)
inline

◆ SetTimeStr()

HRESULT Gray::cTimeDouble::SetTimeStr ( const GChar_t pszDateTime,
TZ_TYPE  nTimeZoneOffset = TZ_UTC 
)

Set the time/date from a string date time . Attempt to determine format from the string/numbers given.

◆ Time()

cTimeDouble Gray::cTimeDouble::Time ( )
static

Time of day now = 0 to 1

Friends And Related Function Documentation

◆ cTimeDoubleTests

friend class cTimeDoubleTests
friend

◆ operator!=

bool operator!= ( const cTimeDouble dt1,
const cTimeDouble dt2 
)
friend

◆ operator<

bool operator< ( const cTimeDouble dt1,
const cTimeDouble dt2 
)
friend

◆ operator<=

bool operator<= ( const cTimeDouble dt1,
const cTimeDouble dt2 
)
friend

◆ operator==

bool operator== ( const cTimeDouble dt1,
const cTimeDouble dt2 
)
friend

◆ operator>

bool operator> ( const cTimeDouble dt1,
const cTimeDouble dt2 
)
friend

◆ operator>=

bool operator>= ( const cTimeDouble dt1,
const cTimeDouble dt2 
)
friend

Member Data Documentation

◆ k_nDaysDiffTimeInt

const int Gray::cTimeDouble::k_nDaysDiffTimeInt = 25569
static

days difference from cTimeDouble (1899) to cTimeInt (1970) bases // similar to linux SECS_1601_TO_1970 ?

◆ k_nY10

const double Gray::cTimeDouble::k_nY10 = 3650.0
static

The first 10 years are sometimes reserved to act as offsets.

◆ k_nY2K

const double Gray::cTimeDouble::k_nY2K = 36526.0
static

The static value for y2k = January 1, 2000 in UTC/GMT.

◆ k_nZero

const int Gray::cTimeDouble::k_nZero = 0
static

double cant be used for in-class initializer

◆ m_dateTime

double Gray::cTimeDouble::m_dateTime
protected

DATE = days since (midnight, 30 December 1899 GMT), fraction = time of day.


The documentation for this class was generated from the following files: