11 #ifndef _MARIADB_TIME_HPP_ 12 #define _MARIADB_TIME_HPP_ 47 time(
const tm& time_struct);
61 time(
const MYSQL_TIME& time);
75 virtual ~time() =
default;
83 int compare(
const time& t)
const;
bool operator<(const time &t) const
Checks if this instance is lesser than t.
u16 millisecond() const
Get the current millisecond 0-999.
Class representing SQL time.
virtual bool is_valid() const
Indicates whether this time is considered valid.
u8 second() const
Get the current second 0-61 (leap second possible)
time & operator=(const time &t)
Assigns a value to this instance.
time subtract(const time_span &dur) const
Subtracts the given timespan from the current time.
u8 minute() const
Get the current minute 0-59.
int compare(const time &t) const
Compare this instance to given instance.
double diff_time(const time &t) const
Calculates the time difference using ::difftime.
bool operator<=(const time &t) const
Checks if this instance is lesser or equal to t.
time add_milliseconds(s32 milliseconds) const
Adds a certain amount of milliseconds to the current time.
std::ostream & operator<<(std::ostream &os, const date_time &ddt)
time(u8 hour=0, u8 minute=0, u8 second=0, u16 millisecond=0)
Construct time using given values.
const std::string str_time(bool with_millisecond=false) const
Converts the time to a string with the format hh:mm:ss[.nnn].
bool operator>(const time &t) const
Checks if this instance is greater than t.
time add_minutes(s32 minutes) const
Adds a certain amount of minutes to the current time.
u8 hour() const
Get the current hour 0-23.
bool operator!=(const time &t) const
Checks for unequality.
bool operator>=(const time &t) const
Checks if this instance is greater or equal to t.
time add_seconds(s32 seconds) const
Adds a certain amount of seconds to the current time.
time add(const time_span &dur) const
Adds the given timespan to the current time.
static time now()
Uses time.h to determine the current time in the local timezone.
time add_hours(s32 hours) const
Adds a certain amount of hours to the current time.
static time now_utc()
Uses time.h to determine the current time in UTC timezone.
time_span time_between(const time &t) const
Calculates the timespan between the current time instance and given instance t.
virtual ~time()=default
Allow proper destruction in derived classes.
static bool valid_time(u8 hour, u8 minute, u8 second, u16 millisecond)
Indicates whether a given time is valid in terms of limits.
time_t mktime() const
Converts the time to time_t (time.h representation)
MYSQL_TIME mysql_time() const
Converts the time to MySQL time representation.
bool operator==(const time &t) const
Checks for equality.