ADTF  3.18.2
cTime

Time class. More...

Inheritance diagram for cTime:
[legend]

Public Member Functions

 cTime ()
 Default constructor.
 
 cTime (tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0)
 Constructor for presetting the stored time. More...
 
 cTime (const tTime *psTime)
 Constructor for presetting the stored time. More...
 
 cTime (const cTime &oTime)
 Copy constructor. More...
 
cTimeoperator= (const cTime &oTime)
 The cTime assignment (=) operator reinitializes an existing cTime object with new data. More...
 
virtual ~cTime ()
 Destructor.
 
tVoid Get (tTime *psTime) const
 Fills a time structure with the stored values. More...
 
tVoid Set (tInt nHour, tInt nMinute, tInt nSecond, tInt nMicroseconds=0)
 Sets the stored time. More...
 
tVoid Set (const tTime *psTime)
 Sets the stored time. More...
 
tVoid Set (const cTime &oTime)
 Sets the stored time. More...
 
tVoid SetHour (tInt nHour)
 Set the hour. More...
 
tInt GetHour () const
 Get the hour. More...
 
tVoid SetMinute (tInt nMinute)
 Set the minute. More...
 
tInt GetMinute () const
 Get the minute. More...
 
tVoid SetSecond (tInt nSecond)
 Set the second. More...
 
tInt GetSecond () const
 Get the second. More...
 
tVoid SetMicroseconds (tInt nMicroseconds)
 Set the microsecond. More...
 
tInt Microseconds () const
 Get the microsecond. More...
 
cString Format (const cString &strFormat) const
 Creates a string representation of the stored time. More...
 
tBool Valid ()
 Check whether or not the stored time is valid. More...
 

Static Public Member Functions

static cTime GetCurrentTime ()
 Get the current time (hardware clock with respect to timezone). More...
 
static cTime GetCurrentSystemTime ()
 Get the current time (in UTC format). More...
 
static tResult GetTimeFromString (cTime &oTime, const cString &strTime)
 Converts a given time string into a time and fill the given time. More...
 
static tInt TimeDiff (const cString &str, const cString &strTime1, const cString &strTime2)
 Calculates the difference between two time strings. More...
 
static tInt TimeDiff (const cString &str, const cTime &oTime1, const cTime &oTime2)
 Calculates the difference between two times. More...
 
static cTime FromTimeStamp (tTimeStamp tmTime)
 Converts a given timestamp into a time. More...
 

Protected Attributes

tTime m_sTime
 Internally used time structure.
 

Detailed Description

Constructor & Destructor Documentation

◆ cTime() [1/3]

cTime ( tInt  nHour,
tInt  nMinute,
tInt  nSecond,
tInt  nMicroseconds = 0 
)

Constructor for presetting the stored time.

Parameters
nHourThe hour.
nMinuteThe minute.
nSecondThe second.
nMicrosecondsThe microsecond.

◆ cTime() [2/3]

cTime ( const tTime psTime)

Constructor for presetting the stored time.

Parameters
psTimeThe time.

◆ cTime() [3/3]

cTime ( const cTime oTime)

Copy constructor.

Parameters
oTime

Member Function Documentation

◆ Format()

cString Format ( const cString strFormat) const

Creates a string representation of the stored time.

Parameters
strFormatThe format of the string representation (see cDateTime::Format, can be empty).
Returns
A string representation of the stored date.

◆ FromTimeStamp()

static cTime FromTimeStamp ( tTimeStamp  tmTime)
static

Converts a given timestamp into a time.

Parameters
[in]tmTimeContains the given time as timestamp in microseconds.
Returns
An object corresponding to tmTime.

◆ Get()

tVoid Get ( tTime psTime) const

Fills a time structure with the stored values.

Parameters
psTimeThe structure to fill.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetCurrentSystemTime()

static cTime GetCurrentSystemTime ( )
static

Get the current time (in UTC format).

Returns
The current time.

◆ GetCurrentTime()

static cTime GetCurrentTime ( )
static

Get the current time (hardware clock with respect to timezone).

Returns
The current time.

◆ GetHour()

tInt GetHour ( ) const

Get the hour.

Returns
The hour.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetMinute()

tInt GetMinute ( ) const

Get the minute.

Returns
The minute.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetSecond()

tInt GetSecond ( ) const

Get the second.

Returns
The second.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ GetTimeFromString()

static tResult GetTimeFromString ( cTime oTime,
const cString strTime 
)
static

Converts a given time string into a time and fill the given time.

This string formats are supported: HH:MM:SS

  • HH Hour in 24-hour format (zero-padded 00..23)
  • MM Minute as decimal number (zero-padded 00..59)
  • SS Second as decimal number (zero-padded 00..59)
  • : Separator for hour:minute:second
Parameters
[out]oTimeThe time to fill according to the given time string.
[in]strTimeThe string contains the given time as string.
Return values
ERR_INVALID_ARGThe time string length is 0 or any unsupported character was found.
ERR_UNKNOWN_FORMATThe time string format is invalid (e.g. H:MM:SS).
ERR_OUT_OF_RANGEThe time is invalid (see cTime::Valid).
ERR_NOERROR

◆ Microseconds()

tInt Microseconds ( ) const

Get the microsecond.

Returns
The microsecond.
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ operator=()

cTime& operator= ( const cTime oTime)

The cTime assignment (=) operator reinitializes an existing cTime object with new data.

Parameters
oTime[in] cTime object to be assigned.
Returns
Reference to accessed cTime object.

◆ Set() [1/3]

tVoid Set ( const cTime oTime)

Sets the stored time.

Parameters
oTimeThe Time.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Set() [2/3]

tVoid Set ( const tTime psTime)

Sets the stored time.

Parameters
psTimeThe time.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ Set() [3/3]

tVoid Set ( tInt  nHour,
tInt  nMinute,
tInt  nSecond,
tInt  nMicroseconds = 0 
)

Sets the stored time.

Parameters
nHourThe hour.
nMinuteThe minute.
nSecondThe second.
nMicrosecondsThe microsecond.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SetHour()

tVoid SetHour ( tInt  nHour)

Set the hour.

Parameters
nHourThe hour.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SetMicroseconds()

tVoid SetMicroseconds ( tInt  nMicroseconds)

Set the microsecond.

Parameters
nMicrosecondsThe microsecond.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SetMinute()

tVoid SetMinute ( tInt  nMinute)

Set the minute.

Parameters
nMinuteThe minute.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ SetSecond()

tVoid SetSecond ( tInt  nSecond)

Set the second.

Parameters
nSecondThe second.
Returns
void
This method is real-time safe.\nSee @ref page_real_time_safe.\n

◆ TimeDiff() [1/2]

static tInt TimeDiff ( const cString str,
const cString strTime1,
const cString strTime2 
)
static

Calculates the difference between two time strings.

Note
The second time has to be later on first time. Daylight-saving time within the two times is not supported.
Parameters
[in]strThe format string of the output.

The formatting codes are listed below:

  • H Difference between two times in hours
  • M Difference between two times in minutes
  • S Difference between two times in seconds
Parameters
[in]strTime1The string contains the first time as string.
[in]strTime2The string contains the second time as string.
Return values
ERR_INVALID_ARGThe output format string length is 0 or any unsupported character was found.
ERR_OUT_OF_RANGEThe first or second time is invalid (see cTime::Valid).
ERR_NOT_SUPPORTEDFirst time is later on second time.
Returns
The difference between two times according to the output format string.

◆ TimeDiff() [2/2]

static tInt TimeDiff ( const cString str,
const cTime oTime1,
const cTime oTime2 
)
static

Calculates the difference between two times.

Note
The second time has to be later on first time. Daylight-saving time within the two times is not supported.
Parameters
[in]strThe format string of the output.

The formatting codes are listed below:

  • H Difference between two times in hours
  • M Difference between two times in minutes
  • S Difference between two times in seconds
Parameters
[in]oTime1The first time.
[in]oTime2The second time.
Return values
ERR_INVALID_ARGThe output format string length is 0 or any unsupported character was found.
ERR_OUT_OF_RANGEThe first or second time is invalid (see cTime::Valid).
ERR_NOT_SUPPORTEDFirst time is later on second time.
Returns
The difference between two times according to the output format string.

◆ Valid()

tBool Valid ( )

Check whether or not the stored time is valid.

Range table:

  • Houre (00..23)
  • Minute (00..59)
  • Second (00..59)
  • Microseconds (0..999999)
Returns
Whether or not the specified time is valid.