BoosterSeat
0.1
A C++ library that includes common utilities that are used in other projects.
|
The generic time class for BoosterSeat. Uses UTC time. More...
#include <time.hpp>
Public Member Functions | |
Time (bool set_to_now=false) | |
Construct a new Time object. Defaults to the epoch. More... | |
~Time ()=default | |
bool | fromString (const std::string &time_string) |
unsigned int | getDay () const |
Get the Day. More... | |
unsigned int | getHour () const |
Get the Hour. More... | |
unsigned int | getMinute () const |
Get the Minute. More... | |
unsigned int | getMonth () const |
Get the Month (1 - 12) More... | |
unsigned int | getSecond () const |
Get the Second. More... | |
time_t | getTimeType () const |
unsigned int | getYear () const |
Get the Year. More... | |
bool | operator!= (const Time &rhs) const |
bool | operator< (const Time &rhs) const |
bool | operator<= (const Time &rhs) const |
bool | operator== (const Time &rhs) const |
bool | operator> (const Time &rhs) const |
bool | operator>= (const Time &rhs) const |
int64_t | secondsFromNow () const |
Returns the number of seconds from the current time to the stored time. More... | |
void | setToNow () |
Set the time to the current time. More... | |
std::string | toString () const |
Get the time/date as a string in the format: YYYY-MM-DD HH:MM:SS. More... | |
Private Attributes | |
time_t | time_ = 0 |
The generic time class for BoosterSeat. Uses UTC time.
bst::Time::Time | ( | bool | set_to_now = false | ) |
Construct a new Time object. Defaults to the epoch.
set_to_now | - Set the time to the current time. Defaults to false. |
References setToNow().
|
default |
void bst::Time::setToNow | ( | ) |
std::string bst::Time::toString | ( | ) | const |
bool bst::Time::fromString | ( | const std::string & | time_string | ) |
time_string | - The time string to parse in the format: YYYY-MM-DD HH:MM:SS |
References time_.
Referenced by TEST().
unsigned int bst::Time::getYear | ( | ) | const |
unsigned int bst::Time::getMonth | ( | ) | const |
unsigned int bst::Time::getDay | ( | ) | const |
unsigned int bst::Time::getHour | ( | ) | const |
unsigned int bst::Time::getMinute | ( | ) | const |
unsigned int bst::Time::getSecond | ( | ) | const |
|
inline |
References time_.
int64_t bst::Time::secondsFromNow | ( | ) | const |
Returns the number of seconds from the current time to the stored time.
References time_.
Referenced by TEST().
|
private |
Referenced by fromString(), getDay(), getHour(), getMinute(), getMonth(), getSecond(), getTimeType(), getYear(), operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), secondsFromNow(), setToNow(), and toString().