ADTF
Loading...
Searching...
No Matches
a_util::datetime::Time Class Reference

#include <datetime.h>

Inherited by a_util::datetime::DateTime.

Public Member Functions

 Time ()
 Default constructor - initializes the time to 00:00:00,0.
 
 Time (int hour, int minute, int second, int microsecond=0)
 
void set (int hour, int minute, int second, int microsecond=0)
 
bool set (const std::string &time)
 
void setHour (int hour)
 
int getHour () const
 
void setMinute (int minute)
 
int getMinute () const
 
void setSecond (int second)
 
int getSecond () const
 
void setMicrosecond (int microsecond)
 
int getMicrosecond () const
 
std::string format (const std::string &format_str) const
 

Detailed Description

Time implementation representing a time of day (00:00:00,0 - 23:59:59,999999)

Warning
: This class does not enforce time consistency!

Constructor & Destructor Documentation

◆ Time()

a_util::datetime::Time::Time ( int hour,
int minute,
int second,
int microsecond = 0 )

Constructor for presetting the stored time.

Parameters
[in]hourThe hour.
[in]minuteThe minute.
[in]secondThe second.
[in]microsecondThe microsecond.

Member Function Documentation

◆ format()

std::string a_util::datetime::Time::format ( const std::string & format_str) const

Creates a string representation of the stored time.

Parameters
[in]format_strThe format of the string representation (see DateTime::format, might be empty).
Returns
A string representation of the stored date.
Exceptions
std::invalid_argumentIf the format string is invalid

◆ getHour()

int a_util::datetime::Time::getHour ( ) const

Get the hour.

Returns
The hour.

◆ getMicrosecond()

int a_util::datetime::Time::getMicrosecond ( ) const

Get the microsecond.

Returns
[in] The microsecond.

◆ getMinute()

int a_util::datetime::Time::getMinute ( ) const

Get the minute.

Returns
The minute.

◆ getSecond()

int a_util::datetime::Time::getSecond ( ) const

Get the second.

Returns
The second.

◆ set() [1/2]

bool a_util::datetime::Time::set ( const std::string & time)

Sets the time a given time string

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
[in]timeThe string contains the given time as string.
Returns
false if the time string format is invalid, true otherwise

◆ set() [2/2]

void a_util::datetime::Time::set ( int hour,
int minute,
int second,
int microsecond = 0 )

Sets the stored time.

Parameters
[in]hourThe hour.
[in]minuteThe minute.
[in]secondThe second.
[in]microsecondThe microsecond.

◆ setHour()

void a_util::datetime::Time::setHour ( int hour)

Set the hour.

Parameters
[in]hourThe hour.

◆ setMicrosecond()

void a_util::datetime::Time::setMicrosecond ( int microsecond)

Set the microsecond.

Parameters
[in]microsecondThe microsecond.

◆ setMinute()

void a_util::datetime::Time::setMinute ( int minute)

Set the minute.

Parameters
[in]minuteThe minute.

◆ setSecond()

void a_util::datetime::Time::setSecond ( int second)

Set the second.

Parameters
[in]secondThe second.

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