TrueReality  v0.1.1912
trUtil::DateTime Class Reference

#include <DateTime.h>

Collaboration diagram for trUtil::DateTime:

Classes

class  TimeFormat
 
class  TimeOrigin
 
class  TimeType
 

Public Member Functions

 DateTime ()
 The default constructor just zeros. More...
 
 DateTime (const TimeOrigin &initAs)
 This constructor takes a TimeOrigin and sets the time accordingly. More...
 
 DateTime (time_t)
 Create a DateTime using the c standard time_t struct. More...
 
 DateTime (const struct tm &)
 Create a DateTime using the c standard struct tm. More...
 
 DateTime (const DateTime &)
 Copy constructor. More...
 
DateTimeoperator= (const DateTime &)
 Assignment operator. More...
 
virtual ~DateTime ()
 Destructor. More...
 
void SetToLocalTime ()
 Changes time to be system local time. More...
 
void SetToGMTTime ()
 Changes time to be GMT- or Greenwich Mean Time. More...
 
void IncrementClock (double seconds)
 Increments the clock time by the number of seconds specified. More...
 
void AdjustTimeZone (float newGMTOffset)
 Every date time has a GMT offset. More...
 
void GetTime (unsigned &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, float &sec) const
 Gets the time internally stored using unsigned year, month, day, hour, minute, and seconds. More...
 
void GetTime (unsigned &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, unsigned &sec) const
 Gets a time. More...
 
void GetGMTTime (unsigned &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, float &sec) const
 Gets the time internally stored using unsigned year, month, day, hour, minute, and seconds. More...
 
void GetGMTTime (unsigned &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, unsigned &sec) const
 Gets GMT time. More...
 
void SetTime (unsigned year, unsigned month, unsigned day, unsigned hour, unsigned min, float sec)
 Sets the full time using year, month, day, hour, minute, and second. More...
 
void SetTime (unsigned year, unsigned month, unsigned day, unsigned hour, unsigned min, unsigned sec)
 Sets a time. More...
 
time_t GetTime () const
 Gets the time in the standard time_t format, specified as seconds elapsed since midnight, January 1, 1970. More...
 
time_t GetGMTTime () const
 Gets the time in standard time_t format, the GMTOffset is added to the time before calculating time_t. More...
 
void SetTime (time_t)
 Sets time in standard time_t format, specified as seconds elapsed since midnight, January 1, 1970. More...
 
double GetTimeInSeconds () const
 Returns the total clock time in seconds elapsed since midnight, January 1, 1970 This time includes fractional seconds. More...
 
void GetTime (tm &) const
 Fills a standard c struct tm with the time. More...
 
void GetGMTTime (tm &) const
 Fills a standard c struct tm with the time but adds GMTOffset into time before struct tm is calculated. More...
 
void SetTime (const tm &)
 Sets the time using the standard c struct tm. More...
 
void SetGMTOffset (float hourOffset, bool dayLightSavings)
 Sets the GMTOffset which is added to the time when getting GMT time,. More...
 
void SetGMTOffset (double lattitude, double longitude, bool dayLightSavings)
 Calculates the GMTOffset using a lattitude and longitude, not 100% correct due to regional time zone boundaries but it works ok as an approximation. More...
 
float GetGMTOffset () const
 Gets the GMTOffset, this will be 0 unless SetGMTOffset was called or SetToLocalTime() was called, or TimeOrigin::LOCAL_TIME was fed into the constructor. More...
 
float GetTimeScale () const
 The TimeScale can be used to scale the time when incrementing the clock. More...
 
void SetTimeScale (float percentScaleInSeconds)
 The TimeScale can be used to scale the time when incrementing the clock. More...
 
const TimeTypeGetTimeType () const
 The TimeType enumeration is used to identify the purpose of a DateTime instance. More...
 
void SetTimeType (const TimeType &)
 The TimeType enumeration is used to identify the purpose of a DateTime instance. More...
 
const TimeOriginGetTimeOrigin () const
 The TimeOrigin enumeration determines how the instance of DateTime should be interpreted. More...
 
void SetTimeOrigin (const TimeOrigin &)
 The TimeOrigin enumeration determines how the instance of DateTime should be interpreted. More...
 
const TimeFormatGetTimeFormat () const
 The TimeFormat enumeration is used to specify how to map a DateTime object to a string. More...
 
void SetTimeFormat (const TimeFormat &)
 The TimeFormat enumeration is used to specify how to map a DateTime object to a string. More...
 
float GetSecond () const
 Gets the second. More...
 
void SetSecond (float sec)
 Sets a second. More...
 
unsigned GetMinute () const
 Gets the minute. More...
 
void SetMinute (unsigned min)
 Sets a minute. More...
 
unsigned GetHour () const
 Gets the hour. More...
 
void SetHour (unsigned hour)
 Sets a hour. More...
 
unsigned GetDay () const
 Gets the day. More...
 
void SetDay (unsigned day)
 Sets a day. More...
 
unsigned GetMonth () const
 Gets the month. More...
 
void SetMonth (unsigned month)
 Sets a month. More...
 
unsigned GetYear () const
 Gets the year. More...
 
void SetYear (unsigned year)
 Sets a year. More...
 
std::string ToString () const
 The no parameter version of ToString uses the internal TimeFormat, see the TimeFormat enumeration above. More...
 
std::string ToString (const TimeFormat &) const
 Converts the time to a string using a TimeFormat enumeration, see the TimeFormat enumeration above. More...
 
 operator time_t () const
 general purpose conversion operators. More...
 
 operator tm () const
 Cast that converts the given to a tm. More...
 
 operator std::string () const
 Cast that converts the given to a string. More...
 

Static Public Member Functions

static float GetLocalGMTOffset (bool accountForDST=false)
 Gets local GMT offset. More...
 
static float CalcGMTOffset (tm &timeParts, bool factorLocalDayLightSavingsIntoGMTOffset)
 Sets the GMTOffset using the systems local time this offset is added to the time when getting GMT time,. More...
 
static std::string ToString (const DateTime &, const TimeFormat &)
 A static version of ToString() for convenience, using the conversion operators a time_t or struct tm can be passed for the DateTime. More...
 

Private Member Functions

void ResetToDefaultValues ()
 Resets to default values. More...
 

Static Private Member Functions

static void GetGMTTime (time_t *t, tm &timeParts)
 Gets GMT time. More...
 
static void GetLocalTime (time_t *t, tm &timeParts)
 Gets local time. More...
 

Private Attributes

float mGMTOffset
 The GMT offset. More...
 
float mTimeScale
 The time scale. More...
 
double mFractionalSeconds
 The fractional in seconds. More...
 
unsigned mSeconds
 
unsigned mMinutes
 
unsigned mHours
 
unsigned mDays
 
unsigned mMonths
 
unsigned mYears
 Store parts of time. More...
 
const TimeOriginmTimeOrigin
 The time origin. More...
 
const TimeTypemTimeType
 Type of the time. More...
 
const TimeFormatmStringFormat
 The string format. More...
 

Detailed Description

Definition at line 44 of file DateTime.h.

Constructor & Destructor Documentation

◆ DateTime() [1/5]

trUtil::DateTime::DateTime ( )

The default constructor just zeros.

Definition at line 65 of file DateTime.cpp.

References ResetToDefaultValues().

Here is the call graph for this function:

◆ DateTime() [2/5]

trUtil::DateTime::DateTime ( const TimeOrigin initAs)

This constructor takes a TimeOrigin and sets the time accordingly.

Parameters
initAsThe init as.

Definition at line 71 of file DateTime.cpp.

References trUtil::DateTime::TimeOrigin::GMT_TIME, trUtil::DateTime::TimeOrigin::LOCAL_TIME, mTimeOrigin, ResetToDefaultValues(), SetToGMTTime(), and SetToLocalTime().

Here is the call graph for this function:

◆ DateTime() [3/5]

trUtil::DateTime::DateTime ( time_t  t)

Create a DateTime using the c standard time_t struct.

Parameters
parameter1The first parameter.

Definition at line 87 of file DateTime.cpp.

References ResetToDefaultValues(), and SetTime().

Here is the call graph for this function:

◆ DateTime() [4/5]

trUtil::DateTime::DateTime ( const struct tm &  t)

Create a DateTime using the c standard struct tm.

Parameters
parameter1The first parameter.

Definition at line 94 of file DateTime.cpp.

References ResetToDefaultValues(), and SetTime().

Here is the call graph for this function:

◆ DateTime() [5/5]

trUtil::DateTime::DateTime ( const DateTime rhs)

Copy constructor.

Parameters
parameter1The first parameter.

Definition at line 102 of file DateTime.cpp.

◆ ~DateTime()

trUtil::DateTime::~DateTime ( )
virtual

Destructor.

Definition at line 127 of file DateTime.cpp.

Member Function Documentation

◆ AdjustTimeZone()

void trUtil::DateTime::AdjustTimeZone ( float  newGMTOffset)

Every date time has a GMT offset.

This method allows one to set a new GMT offset, and then change the clock internally to match the newoffset. For example if the clock is in 12:00 AM Eastern Time (-5) Jan 5, 2009, setting the offset to west coast time (-8) would make the date time be 9:00 PM, Jan 4, 2009.

Parameters
newGMTOffsetthe offset in hours from GMT to change this to.

Definition at line 196 of file DateTime.cpp.

References IncrementClock(), and mGMTOffset.

Here is the call graph for this function:

◆ CalcGMTOffset()

float trUtil::DateTime::CalcGMTOffset ( tm &  timeParts,
bool  factorLocalDayLightSavingsIntoGMTOffset 
)
static

Sets the GMTOffset using the systems local time this offset is added to the time when getting GMT time,.

Parameters
[in,out]timePartsthe struct tm used to calculate the local timezone.
factorLocalDayLightSavingsIntoGMTOffsetthis flag is used to specify whether or not daylight savings should be obtained from the system clock, setting true will increment the GMTOffset by one hour if your system is currently on daylight savings.
Returns
The calculated GMT offset.

Definition at line 401 of file DateTime.cpp.

Referenced by GetLocalGMTOffset(), and SetToLocalTime().

Here is the caller graph for this function:

◆ GetDay()

unsigned trUtil::DateTime::GetDay ( ) const

Gets the day.

Returns
The day.

Definition at line 488 of file DateTime.cpp.

References mDays.

◆ GetGMTOffset()

float trUtil::DateTime::GetGMTOffset ( ) const

Gets the GMTOffset, this will be 0 unless SetGMTOffset was called or SetToLocalTime() was called, or TimeOrigin::LOCAL_TIME was fed into the constructor.

Returns
the current offset from Greenwich mean time.

Definition at line 443 of file DateTime.cpp.

References mGMTOffset.

Referenced by ToString().

Here is the caller graph for this function:

◆ GetGMTTime() [1/5]

void trUtil::DateTime::GetGMTTime ( unsigned &  year,
unsigned &  month,
unsigned &  day,
unsigned &  hour,
unsigned &  min,
float &  sec 
) const

Gets the time internally stored using unsigned year, month, day, hour, minute, and seconds.

The float second version will include the sub second time if IncrementClock() or SetSecond() was not rounded off. The GMTOffset will be added into the current time to obtain the GMT Time.

Parameters
[in,out]yearthe full year, not just since 1900 epoch.
[in,out]monththe month specified as 1-12.
[in,out]daythe day specified as 1-31.
[in,out]hourhours since midnight 0-23.
[in,out]minminutes after the hour 0-60.
[in,out]secseconds after the hour 0-61 (and extra second is added to support leap seconds)

Definition at line 250 of file DateTime.cpp.

References GetGMTTime(), mDays, mHours, mMinutes, mMonths, mSeconds, and mYears.

Here is the call graph for this function:

◆ GetGMTTime() [2/5]

void trUtil::DateTime::GetGMTTime ( unsigned &  year,
unsigned &  month,
unsigned &  day,
unsigned &  hour,
unsigned &  min,
unsigned &  sec 
) const

Gets GMT time.

Parameters
[in,out]yearThe year.
[in,out]monthThe month.
[in,out]dayThe day.
[in,out]hourThe hour.
[in,out]minThe minimum.
[in,out]secThe security.

Definition at line 262 of file DateTime.cpp.

References GetGMTTime(), mDays, mHours, mMinutes, mMonths, mSeconds, and mYears.

Here is the call graph for this function:

◆ GetGMTTime() [3/5]

time_t trUtil::DateTime::GetGMTTime ( ) const

Gets the time in standard time_t format, the GMTOffset is added to the time before calculating time_t.

Returns
The GMT time.

Definition at line 351 of file DateTime.cpp.

References GetTime(), IncrementClock(), and mGMTOffset.

Referenced by GetGMTTime(), GetTime(), SetTime(), and SetToGMTTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGMTTime() [4/5]

void trUtil::DateTime::GetGMTTime ( tm &  timeParts) const

Fills a standard c struct tm with the time but adds GMTOffset into time before struct tm is calculated.

Parameters
[in,out]parameter1The first parameter.

Definition at line 374 of file DateTime.cpp.

References GetTime(), IncrementClock(), and mGMTOffset.

Here is the call graph for this function:

◆ GetGMTTime() [5/5]

void trUtil::DateTime::GetGMTTime ( time_t *  t,
tm &  timeParts 
)
staticprivate

Gets GMT time.

Parameters
[in,out]tIf non-null, the time_t to process.
[in,out]timePartsThe time parts.

Definition at line 659 of file DateTime.cpp.

◆ GetHour()

unsigned trUtil::DateTime::GetHour ( ) const

Gets the hour.

Returns
The hour.

Definition at line 475 of file DateTime.cpp.

References mHours.

◆ GetLocalGMTOffset()

float trUtil::DateTime::GetLocalGMTOffset ( bool  accountForDST = false)
static

Gets local GMT offset.

Parameters
accountForDST(Optional) True to account for destination.
Returns
The local GMT offset.

Definition at line 171 of file DateTime.cpp.

References CalcGMTOffset(), and GetLocalTime().

Here is the call graph for this function:

◆ GetLocalTime()

void trUtil::DateTime::GetLocalTime ( time_t *  t,
tm &  timeParts 
)
staticprivate

Gets local time.

Parameters
[in,out]tIf non-null, the time_t to process.
[in,out]timePartsThe time parts.

Definition at line 678 of file DateTime.cpp.

Referenced by GetLocalGMTOffset(), and SetToLocalTime().

Here is the caller graph for this function:

◆ GetMinute()

unsigned trUtil::DateTime::GetMinute ( ) const

Gets the minute.

Returns
The minute.

Definition at line 463 of file DateTime.cpp.

References mMinutes.

◆ GetMonth()

unsigned trUtil::DateTime::GetMonth ( ) const

Gets the month.

Returns
The month.

Definition at line 501 of file DateTime.cpp.

References mMonths.

Referenced by trUtil::VersionUtil::GetTodaysVersionDate().

Here is the caller graph for this function:

◆ GetSecond()

float trUtil::DateTime::GetSecond ( ) const

Gets the second.

Returns
The second.

Definition at line 449 of file DateTime.cpp.

References mFractionalSeconds, and mSeconds.

◆ GetTime() [1/4]

void trUtil::DateTime::GetTime ( unsigned &  year,
unsigned &  month,
unsigned &  day,
unsigned &  hour,
unsigned &  min,
float &  sec 
) const

Gets the time internally stored using unsigned year, month, day, hour, minute, and seconds.

The float second version will include the sub second time if IncrementClock() or SetSecond() was not rounded off. To get time modified by a GMTOffset use GetGMTTime().

Parameters
[in,out]yearthe full year, not just since 1900 epoch.
[in,out]monththe month specified as 1-12.
[in,out]daythe day specified as 1-31.
[in,out]hourhours since midnight 0-23.
[in,out]minminutes after the hour 0-60.
[in,out]secseconds after the hour 0-61 (and extra second is added to support leap seconds)

Definition at line 228 of file DateTime.cpp.

References mDays, mHours, mMinutes, mMonths, mSeconds, and mYears.

Referenced by GetGMTTime().

Here is the caller graph for this function:

◆ GetTime() [2/4]

void trUtil::DateTime::GetTime ( unsigned &  year,
unsigned &  month,
unsigned &  day,
unsigned &  hour,
unsigned &  min,
unsigned &  sec 
) const

Gets a time.

Parameters
[in,out]yearThe year.
[in,out]monthThe month.
[in,out]dayThe day.
[in,out]hourThe hour.
[in,out]minThe minimum.
[in,out]secThe security.

Definition at line 239 of file DateTime.cpp.

References mDays, mHours, mMinutes, mMonths, mSeconds, and mYears.

◆ GetTime() [3/4]

time_t trUtil::DateTime::GetTime ( ) const

Gets the time in the standard time_t format, specified as seconds elapsed since midnight, January 1, 1970.

Note
this format only includes whole seconds.
Returns
The time.

On many systems it is ambiguous if mktime() assumes the input is in GMT, or local timezone. To address this, a new function called timegm() is appearing. It works exactly like mktime() but explicitely interprets the input as GMT.

timegm() is available and documented under FreeBSD. It is available, but completely undocumented on my current Debian 2.1 distribution.

In the absence of timegm() we have to guess what mktime() might do.

Many older BSD style systems have a mktime() that assumes the input time in GMT. But FreeBSD explicitly states that mktime() assumes local time zone

The mktime() on many SYSV style systems (such as Linux) usually returns its result assuming you have specified the input time in your local timezone. Therefore, in the absence if timegm() you have to go to extra trouble to convert back to GMT.

If you are having problems with incorrectly positioned astronomical bodies, this is a really good place to start looking.

Definition at line 304 of file DateTime.cpp.

References mDays, mHours, mMinutes, mMonths, mSeconds, and mYears.

Referenced by GetGMTTime(), GetTime(), GetTimeInSeconds(), operator time_t(), and operator tm().

Here is the caller graph for this function:

◆ GetTime() [4/4]

void trUtil::DateTime::GetTime ( tm &  timeParts) const

Fills a standard c struct tm with the time.

Parameters
[in,out]parameter1The first parameter.

Definition at line 367 of file DateTime.cpp.

References GetGMTTime(), and GetTime().

Here is the call graph for this function:

◆ GetTimeFormat()

const DateTime::TimeFormat & trUtil::DateTime::GetTimeFormat ( ) const

The TimeFormat enumeration is used to specify how to map a DateTime object to a string.

Set the TimeFormat if you would like to use the ToString() without any arguments.

Returns
The time format.

Definition at line 565 of file DateTime.cpp.

References mStringFormat.

◆ GetTimeInSeconds()

double trUtil::DateTime::GetTimeInSeconds ( ) const

Returns the total clock time in seconds elapsed since midnight, January 1, 1970 This time includes fractional seconds.

Returns
The time in seconds.

Definition at line 298 of file DateTime.cpp.

References GetTime(), and mFractionalSeconds.

Here is the call graph for this function:

◆ GetTimeOrigin()

const DateTime::TimeOrigin & trUtil::DateTime::GetTimeOrigin ( ) const

The TimeOrigin enumeration determines how the instance of DateTime should be interpreted.

Returns
The time origin.

Definition at line 552 of file DateTime.cpp.

References mTimeOrigin.

◆ GetTimeScale()

float trUtil::DateTime::GetTimeScale ( void  ) const

The TimeScale can be used to scale the time when incrementing the clock.

The default value for TimeScale is 1.0.

Returns
The time scale.

Definition at line 527 of file DateTime.cpp.

References mTimeScale.

◆ GetTimeType()

const DateTime::TimeType & trUtil::DateTime::GetTimeType ( ) const

The TimeType enumeration is used to identify the purpose of a DateTime instance.

Returns
The time type.

Definition at line 540 of file DateTime.cpp.

References mTimeType.

◆ GetYear()

unsigned trUtil::DateTime::GetYear ( ) const

Gets the year.

Returns
The year.

Definition at line 514 of file DateTime.cpp.

References mYears.

Referenced by trUtil::VersionUtil::GetTodaysVersionDate().

Here is the caller graph for this function:

◆ IncrementClock()

void trUtil::DateTime::IncrementClock ( double  seconds)

Increments the clock time by the number of seconds specified.

The fractional part of the time is saved off and added in whole increments to support sub second times but getting time as a time_t or struct tm will not include fractional seconds. To get the fractional seconds use GetTime with a float for seconds or GetSecond().

Parameters
secondsnumber of seconds to increase the clock by.

Definition at line 181 of file DateTime.cpp.

References mFractionalSeconds, mTimeScale, and SetTime().

Referenced by AdjustTimeZone(), and GetGMTTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator std::string()

trUtil::DateTime::operator std::string ( ) const

Cast that converts the given to a string.

Returns
The result of the operation.

Definition at line 165 of file DateTime.cpp.

References ToString().

Here is the call graph for this function:

◆ operator time_t()

trUtil::DateTime::operator time_t ( ) const

general purpose conversion operators.

Returns
The result of the operation.

Definition at line 151 of file DateTime.cpp.

References GetTime().

Here is the call graph for this function:

◆ operator tm()

trUtil::DateTime::operator tm ( ) const

Cast that converts the given to a tm.

Returns
The result of the operation.

Definition at line 157 of file DateTime.cpp.

References GetTime().

Here is the call graph for this function:

◆ operator=()

DateTime & trUtil::DateTime::operator= ( const DateTime rhs)

Assignment operator.

Parameters
parameter1The first parameter.
Returns
A shallow copy of this object.

Definition at line 108 of file DateTime.cpp.

References mDays, mFractionalSeconds, mGMTOffset, mHours, mMinutes, mMonths, mSeconds, mStringFormat, mTimeOrigin, mTimeScale, mTimeType, and mYears.

◆ ResetToDefaultValues()

void trUtil::DateTime::ResetToDefaultValues ( )
private

◆ SetDay()

void trUtil::DateTime::SetDay ( unsigned  day)

Sets a day.

Parameters
dayThe day.

Definition at line 494 of file DateTime.cpp.

References mDays.

◆ SetGMTOffset() [1/2]

void trUtil::DateTime::SetGMTOffset ( float  hourOffset,
bool  dayLightSavings 
)

Sets the GMTOffset which is added to the time when getting GMT time,.

Parameters
hourOffsetthe number of hours to offset from GMT Time, the param is a float to support half hour time zones.
dayLightSavingsthis flag is used to specify whether or not daylight savings is in effect setting this flag to true will add and extra hour to the GMTOffset.

Definition at line 395 of file DateTime.cpp.

References mGMTOffset.

◆ SetGMTOffset() [2/2]

void trUtil::DateTime::SetGMTOffset ( double  lattitude,
double  longitude,
bool  dayLightSavings 
)

Calculates the GMTOffset using a lattitude and longitude, not 100% correct due to regional time zone boundaries but it works ok as an approximation.

Parameters
lattitudethe geographical lattitude of origin.
longitudethe geographical longitude of origin.
dayLightSavingsthis flag is used to specify whether or not daylight savings is in effect setting this flag to true will add and extra hour to the GMTOffset.

Definition at line 430 of file DateTime.cpp.

References mGMTOffset.

◆ SetHour()

void trUtil::DateTime::SetHour ( unsigned  hour)

Sets a hour.

Parameters
hourThe hour.

Definition at line 481 of file DateTime.cpp.

References mHours.

◆ SetMinute()

void trUtil::DateTime::SetMinute ( unsigned  min)

Sets a minute.

Parameters
minThe minimum.

Definition at line 469 of file DateTime.cpp.

References mMinutes.

◆ SetMonth()

void trUtil::DateTime::SetMonth ( unsigned  month)

Sets a month.

Parameters
monthThe month.

Definition at line 507 of file DateTime.cpp.

References mMonths.

◆ SetSecond()

void trUtil::DateTime::SetSecond ( float  sec)

Sets a second.

Parameters
secThe security.

Definition at line 455 of file DateTime.cpp.

References mFractionalSeconds, and mSeconds.

◆ SetTime() [1/4]

void trUtil::DateTime::SetTime ( unsigned  year,
unsigned  month,
unsigned  day,
unsigned  hour,
unsigned  min,
float  sec 
)

Sets the full time using year, month, day, hour, minute, and second.

A float version is provided to support sub second times.

Parameters
yearthe full year, not just since 1900 epoch.
monththe month specified as 1-12.
daythe day specified as 1-31.
hourhours since midnight 0-23.
minminutes after the hour 0-60.
secseconds after the hour 0-61 (and extra second is added to support leap seconds)

Definition at line 274 of file DateTime.cpp.

References mDays, mFractionalSeconds, mHours, mMinutes, mMonths, mSeconds, and mYears.

Referenced by DateTime(), IncrementClock(), SetTime(), SetToGMTTime(), and SetToLocalTime().

Here is the caller graph for this function:

◆ SetTime() [2/4]

void trUtil::DateTime::SetTime ( unsigned  year,
unsigned  month,
unsigned  day,
unsigned  hour,
unsigned  min,
unsigned  sec 
)

Sets a time.

Parameters
yearThe year.
monthThe month.
dayThe day.
hourThe hour.
minThe minimum.
secThe security.

Definition at line 286 of file DateTime.cpp.

References mDays, mFractionalSeconds, mHours, mMinutes, mMonths, mSeconds, and mYears.

◆ SetTime() [3/4]

void trUtil::DateTime::SetTime ( time_t  t)

Sets time in standard time_t format, specified as seconds elapsed since midnight, January 1, 1970.

Parameters
parameter1The first parameter.

Definition at line 359 of file DateTime.cpp.

References GetGMTTime(), and SetTime().

Here is the call graph for this function:

◆ SetTime() [4/4]

void trUtil::DateTime::SetTime ( const tm &  mt)

Sets the time using the standard c struct tm.

Parameters
parameter1The first parameter.

Definition at line 382 of file DateTime.cpp.

References mDays, mFractionalSeconds, mHours, mMinutes, mMonths, mSeconds, and mYears.

◆ SetTimeFormat()

void trUtil::DateTime::SetTimeFormat ( const TimeFormat tf)

The TimeFormat enumeration is used to specify how to map a DateTime object to a string.

Set the TimeFormat if you would like to use the ToString() without any arguments.

Parameters
parameter1The first parameter.

Definition at line 571 of file DateTime.cpp.

References mStringFormat.

◆ SetTimeOrigin()

void trUtil::DateTime::SetTimeOrigin ( const TimeOrigin to)

The TimeOrigin enumeration determines how the instance of DateTime should be interpreted.

Parameters
parameter1The first parameter.

Definition at line 558 of file DateTime.cpp.

References mTimeOrigin.

◆ SetTimeScale()

void trUtil::DateTime::SetTimeScale ( float  percentScaleInSeconds)

The TimeScale can be used to scale the time when incrementing the clock.

The default value for TimeScale is 1.0.

Parameters
percentScaleInSecondsThe percent scale in seconds.

Definition at line 533 of file DateTime.cpp.

References mTimeScale.

◆ SetTimeType()

void trUtil::DateTime::SetTimeType ( const TimeType tt)

The TimeType enumeration is used to identify the purpose of a DateTime instance.

Parameters
parameter1The first parameter.

Definition at line 546 of file DateTime.cpp.

References mTimeType.

◆ SetToGMTTime()

void trUtil::DateTime::SetToGMTTime ( )

Changes time to be GMT- or Greenwich Mean Time.

Definition at line 216 of file DateTime.cpp.

References GetGMTTime(), mFractionalSeconds, mGMTOffset, and SetTime().

Referenced by DateTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetToLocalTime()

void trUtil::DateTime::SetToLocalTime ( )

Changes time to be system local time.

Definition at line 205 of file DateTime.cpp.

References CalcGMTOffset(), GetLocalTime(), mFractionalSeconds, mGMTOffset, and SetTime().

Referenced by DateTime(), trUtil::Logging::Log::LogMessage(), and trUtil::Logging::LogWriterFile::TimeTag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetYear()

void trUtil::DateTime::SetYear ( unsigned  year)

Sets a year.

Parameters
yearThe year.

Definition at line 520 of file DateTime.cpp.

References mYears.

◆ ToString() [1/3]

std::string trUtil::DateTime::ToString ( ) const

The no parameter version of ToString uses the internal TimeFormat, see the TimeFormat enumeration above.

Returns
A std::string that represents this object.

Definition at line 577 of file DateTime.cpp.

References mStringFormat.

Referenced by trUtil::Logging::LogWriterConsole::LogMessage(), trUtil::Logging::LogWriterFile::LogMessage(), operator std::string(), trUtil::Logging::LogWriterFile::TimeTag(), and ToString().

Here is the caller graph for this function:

◆ ToString() [2/3]

◆ ToString() [3/3]

std::string trUtil::DateTime::ToString ( const DateTime dt,
const TimeFormat tf 
)
static

A static version of ToString() for convenience, using the conversion operators a time_t or struct tm can be passed for the DateTime.

Parameters
parameter1The first parameter.
parameter2The second parameter.
Returns
A std::string that represents this object.

Definition at line 583 of file DateTime.cpp.

References ToString().

Here is the call graph for this function:

Member Data Documentation

◆ mDays

unsigned trUtil::DateTime::mDays
private

Definition at line 833 of file DateTime.h.

Referenced by GetDay(), GetGMTTime(), GetTime(), operator=(), ResetToDefaultValues(), SetDay(), and SetTime().

◆ mFractionalSeconds

double trUtil::DateTime::mFractionalSeconds
private

The fractional in seconds.

Definition at line 824 of file DateTime.h.

Referenced by GetSecond(), GetTimeInSeconds(), IncrementClock(), operator=(), ResetToDefaultValues(), SetSecond(), SetTime(), SetToGMTTime(), and SetToLocalTime().

◆ mGMTOffset

float trUtil::DateTime::mGMTOffset
private

◆ mHours

unsigned trUtil::DateTime::mHours
private

Definition at line 833 of file DateTime.h.

Referenced by GetGMTTime(), GetHour(), GetTime(), operator=(), ResetToDefaultValues(), SetHour(), and SetTime().

◆ mMinutes

unsigned trUtil::DateTime::mMinutes
private

◆ mMonths

unsigned trUtil::DateTime::mMonths
private

◆ mSeconds

unsigned trUtil::DateTime::mSeconds
private

◆ mStringFormat

const TimeFormat* trUtil::DateTime::mStringFormat
private

The string format.

Definition at line 840 of file DateTime.h.

Referenced by GetTimeFormat(), operator=(), ResetToDefaultValues(), SetTimeFormat(), and ToString().

◆ mTimeOrigin

const TimeOrigin* trUtil::DateTime::mTimeOrigin
private

The time origin.

Definition at line 836 of file DateTime.h.

Referenced by DateTime(), GetTimeOrigin(), operator=(), ResetToDefaultValues(), and SetTimeOrigin().

◆ mTimeScale

float trUtil::DateTime::mTimeScale
private

The time scale.

Definition at line 822 of file DateTime.h.

Referenced by GetTimeScale(), IncrementClock(), operator=(), ResetToDefaultValues(), and SetTimeScale().

◆ mTimeType

const TimeType* trUtil::DateTime::mTimeType
private

Type of the time.

Definition at line 838 of file DateTime.h.

Referenced by GetTimeType(), operator=(), ResetToDefaultValues(), and SetTimeType().

◆ mYears

unsigned mSeconds mMinutes mHours mDays mMonths trUtil::DateTime::mYears
private

Store parts of time.

Returns
The m years.

Definition at line 833 of file DateTime.h.

Referenced by GetGMTTime(), GetTime(), GetYear(), operator=(), ResetToDefaultValues(), SetTime(), and SetYear().


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