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

< similar to the MFC CTime and cTimeSpan, not as accurate or large ranged as COleDateTime More...

#include <cTimeInt.h>

Inheritance diagram for Gray::cTimeInt:
Gray::CTime

Public Member Functions

 cTimeInt ()
 
 cTimeInt (TIMESEC_t time)
 
 cTimeInt (const cTimeFile &fileTime)
 
 cTimeInt (const cTimeUnits &rTu)
 
 cTimeInt (double dTimeDays)
 
void InitTimeNow ()
 
void InitTimeNowPlusSec (TIMESECD_t iOffsetInSeconds)
 
void InitTime (TIMESEC_t nTime=k_nZero)
 
cTimeFile GetAsFileTime () const
 
bool GetTimeUnits (OUT cTimeUnits &rTu, TZ_TYPE nTimeZoneOffset=TZ_UTC) const
 
TIMESECD_t GetSecondsSince (const cTimeInt &time) const
 
TIMESECD_t get_TimeTilSec () const
 
TIMESECD_t get_AgeSec () const
 
bool isTimeFuture () const
 
bool isTimeValid () const
 
int get_TotalDays () const
 
HRESULT SetTimeStr (const GChar_t *pszTimeDate, TZ_TYPE nTimeZoneOffset=TZ_LOCAL)
 
StrLen_t GetTimeFormStr (GChar_t *pszOut, StrLen_t iOutSizeMax, const GChar_t *pszFormat, TZ_TYPE nTimeZoneOffset=TZ_LOCAL) const
 
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
 
- Public Member Functions inherited from Gray::CTime
 CTime (TIMESEC_t nTime=((TIMESEC_t) 0)) noexcept
 
 CTime (const cTimeFile &fileTime, int nDST=-1)
 
const CTimeoperator= (const CTime &timeSrc) noexcept
 
const CTimeoperator= (TIMESEC_t nTime) noexcept
 
bool operator<= (TIMESEC_t nTime) const noexcept
 
bool operator== (TIMESEC_t nTime) const noexcept
 
bool operator!= (TIMESEC_t nTime) const noexcept
 
bool operator>= (CTime ttime) const noexcept
 
 operator TIMESEC_t () const noexcept
 
TIMESEC_t GetTime () const noexcept
 
TIMESEC_t GetTotalSeconds () const noexcept
 

Static Public Member Functions

static TIMESEC_t __stdcall GetTimeFromDays (double dTimeDays) noexcept
 
static cTimeInt __stdcall GetTimeFromStr (const GChar_t *pszDateTime, TZ_TYPE nTimeZoneOffset)
 
static cTimeInt __stdcall GetTimeNow () noexcept
 
static cTimeInt __stdcall GetCurrentTime () noexcept
 
static bool IsTimeValid (TIMESEC_t nTime)
 
static cString __stdcall GetTimeSpanStr (TIMESECD_t dwSeconds, TIMEUNIT_TYPE eUnitHigh=TIMEUNIT_Day, int iUnitsDesired=2, bool bShortText=false)
 
static cString __stdcall GetTimeDeltaBriefStr (TIMESECD_t dwSeconds)
 
static cString __stdcall GetTimeDeltaSecondsStr (TIMESECD_t dwSeconds)
 

Static Public Attributes

static const TIMESEC_t k_nZero = ((TIMESEC_t)0)
 January 1, 1970 UTC. More...
 
static const TIMESEC_t k_nY2K = ((TIMESEC_t)0x386d4380)
 The static value for Y2K = January 1, 2000 in UTC/GMT from k_nZero in seconds. More...
 

Protected Member Functions

bool InitTimeUnits (const cTimeUnits &rTu)
 

Friends

class cTimeIntTests
 

Additional Inherited Members

- Protected Attributes inherited from Gray::CTime
TIMESEC_t m_time
 Seconds. Essentially the UNIX long time format. (not usable after 2018 unless 64 bit?) More...
 

Detailed Description

< similar to the MFC CTime and cTimeSpan, not as accurate or large ranged as COleDateTime

< no need to dupe MFC function.

the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC), according to the system clock ASSUME __time64_t is signed! MFC uses __time64_t Same as UNIX_TIMESTAMP() for MySQL

Note
32 bit version of this has a clock rollover in 2038.

Constructor & Destructor Documentation

◆ cTimeInt() [1/5]

Gray::cTimeInt::cTimeInt ( )
inline

◆ cTimeInt() [2/5]

Gray::cTimeInt::cTimeInt ( TIMESEC_t  time)
inline

◆ cTimeInt() [3/5]

Gray::cTimeInt::cTimeInt ( const cTimeFile fileTime)
inline
Note
both are UTC so nDST makes no sense. What is MFC thinking ??

◆ cTimeInt() [4/5]

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

◆ cTimeInt() [5/5]

Gray::cTimeInt::cTimeInt ( double  dTimeDays)
inline

Member Function Documentation

◆ get_AgeSec()

TIMESECD_t Gray::cTimeInt::get_AgeSec ( ) const
inline

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

◆ get_TimeTilSec()

TIMESECD_t Gray::cTimeInt::get_TimeTilSec ( ) const
inline

difference in seconds

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

◆ get_TotalDays()

int Gray::cTimeInt::get_TotalDays ( ) const
inline

Needs to be more consistent than accurate. just for compares. Should turn over at midnight.

◆ GetAsFileTime()

cTimeFile Gray::cTimeInt::GetAsFileTime ( ) const
Returns
cTimeFile = 64-bit 100-nanosecond since January 1, 1601 GMT

◆ GetCurrentTime()

static cTimeInt __stdcall Gray::cTimeInt::GetCurrentTime ( )
inlinestaticnoexcept

Alternate name for MFC.

Note
GetCurrentTime() is "#define" by _WIN32 to GetTickCount() so i cant use that name!

◆ GetSecondsSince()

TIMESECD_t Gray::cTimeInt::GetSecondsSince ( const cTimeInt time) const
inline

difference in seconds,

  • = this is in the past. (time in future)
  • = this is in the future. (time in past)

◆ GetTimeDeltaBriefStr()

cString GRAYCALL Gray::cTimeInt::GetTimeDeltaBriefStr ( TIMESECD_t  dwSeconds)
static

Describe a range of time in text. Get a short text description of amount of time (delta) e.g. "2h 2m 2s"

◆ GetTimeDeltaSecondsStr()

cString GRAYCALL Gray::cTimeInt::GetTimeDeltaSecondsStr ( TIMESECD_t  dwSeconds)
static

Full time description. (up to hours) NOT days e.g. "x hours and y minutes and z seconds"

◆ GetTimeFormStr() [1/3]

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

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

  • pszFormat = (const char*) TIME_FORMAT_DEFAULT nTimeZoneOffset = (seconds) what TZ was this recorded in (_timezone), TZ_UTC, TZ_GMT, TZ_EST, TZ_LOCAL

◆ GetTimeFormStr() [2/3]

StrLen_t Gray::cTimeInt::GetTimeFormStr ( GChar_t pszOut,
StrLen_t  iOutSizeMax,
const GChar_t pszFormat,
TZ_TYPE  nTimeZoneOffset = TZ_LOCAL 
) const

MFC just calls this "Format"

◆ GetTimeFormStr() [3/3]

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

◆ GetTimeFromDays()

TIMESEC_t GRAYCALL Gray::cTimeInt::GetTimeFromDays ( double  dTimeDays)
staticnoexcept

Set to time in seconds from time in days. Opposite of cTimeDouble::GetTimeFromSec()

◆ GetTimeFromStr()

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

◆ GetTimeNow()

cTimeInt GRAYCALL Gray::cTimeInt::GetTimeNow ( )
staticnoexcept
Returns
The current time in seconds since Jan 1 1970 GMT (NOT LOCALIZED)
Note
GetCurrentTime() is "#define" by _WIN32 to GetTickCount() so i cant use that name! NOT adjusted for local time zone or DST.

◆ GetTimeSpanStr()

cString GRAYCALL Gray::cTimeInt::GetTimeSpanStr ( TIMESECD_t  dwSeconds,
TIMEUNIT_TYPE  eUnitHigh = TIMEUNIT_Day,
int  iUnitsDesired = 2,
bool  bShortText = false 
)
static

Describe a range of time in text. Get a text description of amount of time (delta)

  • eUnitHigh = the highest unit, TIMEUNIT_Day, TIMEUNIT_Minute iUnitsDesired = the number of units up the cTimeUnits::k_Units ladder to go. default=2

◆ GetTimeUnits()

bool Gray::cTimeInt::GetTimeUnits ( OUT cTimeUnits rTu,
TZ_TYPE  nTimeZoneOffset = TZ_UTC 
) const

Get cTimeUnits for seconds since Jan 1 1970 GMT nTimeZoneOffset = TZ_UTC, TZ_GMT, TZ_LOCAL (adjust for DST and TZ) similar to "::gmtime()" or "::localtime()"

◆ InitTime()

void Gray::cTimeInt::InitTime ( TIMESEC_t  nTime = k_nZero)
  • itime <= 0 = invalid time.

◆ InitTimeNow()

void Gray::cTimeInt::InitTimeNow ( )

Now();

◆ InitTimeNowPlusSec()

void Gray::cTimeInt::InitTimeNowPlusSec ( TIMESECD_t  iOffsetInSeconds)
Note
Assume iOffset is in seconds
ASSUME TIMESEC_t is signed.

◆ InitTimeUnits()

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

Set time in seconds since Jan 1 1970 GMT from cTimeUnits Similar to the MFC CTime::CTime( const FILETIME& ft, int nDST = -1 ) similar to "::mktime()" ASSUME _tzset() has been called and _timezone is set. nTimeZoneOffset = how to deal with DST ? TZ_UTC does not use DST. assume all others do.

◆ isTimeFuture()

bool Gray::cTimeInt::isTimeFuture ( ) const
inline

◆ isTimeValid()

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

MFC does 64 -> 32 bits.

◆ IsTimeValid()

static bool Gray::cTimeInt::IsTimeValid ( TIMESEC_t  nTime)
inlinestatic

◆ SetTimeStr()

HRESULT Gray::cTimeInt::SetTimeStr ( const GChar_t pszTimeDate,
TZ_TYPE  nTimeZoneOffset = TZ_LOCAL 
)

Read the full date format (from Web pages etc) and make it into a cTimeInt value. (local TZ)

  • nTimeZoneOffset = (seconds) what TZ was this recorded in (_timezone) (typically TZ_EST) ?? we have no idea is our local offset for DST is the same as encoded! did the creator of pszDateTime adjust for DST ? tm_isdst
    Returns
    m_time = the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC), according to the system clock true = OK e.g. "Sat, 07 Aug 2004 01:20:20", ""

Friends And Related Function Documentation

◆ cTimeIntTests

friend class cTimeIntTests
friend

Member Data Documentation

◆ k_nY2K

const TIMESEC_t Gray::cTimeInt::k_nY2K = ((TIMESEC_t)0x386d4380)
static

The static value for Y2K = January 1, 2000 in UTC/GMT from k_nZero in seconds.

◆ k_nZero

const TIMESEC_t Gray::cTimeInt::k_nZero = ((TIMESEC_t)0)
static

January 1, 1970 UTC.


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