Evo C++ Library v0.5.1
|
#include <evo/time.h>
Structure holding a time of day.
Output:
Public Member Functions | |
TimeOfDay () | |
Constructor. More... | |
TimeOfDay (int hour, int min=0, int sec=0, int msec=0) | |
Constructor to initialize with time of day. More... | |
TimeOfDay (const TimeOfDay &src) | |
Copy constructor. More... | |
void | add_milliseconds (int milliseconds) |
Add milliseconds to current time, subtract if negative. More... | |
void | add_minutes (int minutes) |
Add minutes to current time, subtract if negative. More... | |
void | add_seconds (int seconds) |
Add seconds to current time, subtract if negative. More... | |
int | compare (const TimeOfDay &oth) const |
Compare to another time of day. More... | |
template<class T > | |
T & | format (T &out, char delim=':', char msdelim=0) const |
Format time of day to String or Stream. More... | |
int | get_days () const |
Get number of days from current hour value. More... | |
int | get_days (int &result_hour) const |
Get number of days and hours from current hour value. More... | |
double | get_fraction () const |
Get current time as a day fraction. More... | |
bool | operator!= (const TimeOfDay &oth) const |
Compare for inequality with another time of day. More... | |
bool | operator< (const TimeOfDay &oth) const |
Compare whether less than another time of day. More... | |
bool | operator<= (const TimeOfDay &oth) const |
Compare whether less than or equal to another time of day. More... | |
TimeOfDay & | operator= (const TimeOfDay &src) |
Assignment operator. More... | |
bool | operator== (const TimeOfDay &oth) const |
Compare for equality with another time of day. More... | |
bool | operator> (const TimeOfDay &oth) const |
Compare whether greater than another time of day. More... | |
bool | operator>= (const TimeOfDay &oth) const |
Compare whether greater than or equal to another time of day. More... | |
bool | parse (const SubString &str, bool allow_hour_overflow=false) |
Set time of day from parsing standard time string. More... | |
bool | parse_std_impl (const char *&inp, const char *end, bool allow_hour_overflow=false) |
Set time of day from parsing standard time string (used internally). More... | |
void | set () |
Set all fields to 0, which is a valid time (midnight). More... | |
bool | set (int new_hour, int new_minute=0, int new_second=0, int new_msecond=0) |
Set new time of day fields. More... | |
void | set_fraction (double tm, int msec=0) |
Set time fields from day fraction. More... | |
void | set_local () |
Set to current local time of day. More... | |
void | set_utc () |
Set to current UTC time of day. More... | |
bool | validate (bool allow_hour_overflow=false) const |
Validate current time of day. More... | |
Public Attributes | |
int | hour |
Hour of day (0 - 23) More... | |
int | minute |
Minute of hour (0 - 59) More... | |
int | msecond |
Millisecond of second (0 - 999) More... | |
int | second |
Second of minute (0 - 60), 60 is a special case for a leap second (rare) More... | |
Static Public Attributes | |
static const int | HOUR_MAX = 23 |
Maximum hour value. More... | |
static const int | HOUR_MIN = 0 |
Minimum hour value. More... | |
static const int | HOURS_PER_DAY = 24 |
Number of hours per day. More... | |
static const int | MIN_PER_DAY = 1440 |
Number of minutes per day. More... | |
static const int | MIN_PER_HOUR = 60 |
Number of minutes per hour. More... | |
static const int | MINUTE_MAX = 59 |
Maximum minute value. More... | |
static const int | MINUTE_MIN = 0 |
Minimum minute value. More... | |
static const long | MSEC_PER_DAY = 86400000 |
Number of milliseconds per day. More... | |
static const long | MSEC_PER_HOUR = 3600000 |
Number of milliseconds per hour. More... | |
static const int | MSEC_PER_MIN = 60000 |
Number of milliseconds per minute. More... | |
static const int | MSEC_PER_SEC = 1000 |
Number of milliseconds per second. More... | |
static const int | MSECOND_MAX = 999 |
Maximum millisecond value. More... | |
static const int | MSECOND_MIN = 0 |
Minimum millisecond value. More... | |
static const int | SEC_PER_DAY = 86400 |
Number of seconds per day. More... | |
static const int | SEC_PER_HOUR = 3600 |
Number of seconds per hour. More... | |
static const int | SEC_PER_MIN = 60 |
Number of seconds per minute. More... | |
static const int | SECOND_MAX = 60 |
Maximum second value. More... | |
static const int | SECOND_MIN = 0 |
Minimum second value. More... | |
|
inline |
Constructor.
|
inline |
Constructor to initialize with time of day.
hour | Hour of day |
min | Minute of hour |
sec | Second of minute |
msec | Millisecond of second |
|
inline |
Add milliseconds to current time, subtract if negative.
milliseconds | Number of milliseconds to add, negative to subtract |
|
inline |
Add minutes to current time, subtract if negative.
minutes | Number of minutes to add, negative to subtract |
|
inline |
Add seconds to current time, subtract if negative.
seconds | Number of seconds to add, negative to subtract |
|
inline |
Compare to another time of day.
oth | Other time of day to compare to |
|
inline |
Format time of day to String or Stream.
T | String/Stream type, inferred from argument |
out | Output String/Stream to format to |
delim | Time delimiter, 0 for none, ':' for standard – other delimiters are not supported by parse() |
msdelim | Delimiter for milliseconds, 0 to not format milliseconds |
out
|
inline |
Get number of days from current hour value.
24
|
inline |
Get number of days and hours from current hour value.
result_hour
value and results are normalized so hour isn't negative (when current input hour is negative)hour=47
returns 1 day, 23 hours
hour=-47
returns -2 days, 1 hour
result_hour | Stores result hour |
|
inline |
Get current time as a day fraction.
0.0
for midnight0.25
for 6 AM0.5
for noon0.75
for 6 PM0.0
for midnight, 0.5
for noon, etc
|
inline |
Compare for inequality with another time of day.
oth | Other time of day to compare to |
|
inline |
Compare whether less than another time of day.
oth | Other time of day to compare to |
|
inline |
Compare whether less than or equal to another time of day.
oth | Other time of day to compare to |
Assignment operator.
src | Source to copy |
|
inline |
Compare for equality with another time of day.
oth | Other time of day to compare to |
|
inline |
Compare whether greater than another time of day.
oth | Other time of day to compare to |
|
inline |
Compare whether greater than or equal to another time of day.
oth | Other time of day to compare to |
|
inline |
Set time of day from parsing standard time string.
HH:MM:SS
– full time of day with delimiters, but without millisecondsHH:MM
– time of day with delimiter and only hour and minuteHH
– time of day with only hour valueHHMM
– time of day with hour and minute, without delimimterHHMMSS
– full time of day without delimitersHH:MM:SS.fff
or HHMMSS.fff
– full time of day with fractional second (milliseconds)HH:MM.fff
or HHMM.fff
– full time of day with fractional minute (to give second and millisecond values)HH.fff
or HH.fff
– full time of day with fractional hour (to give minute, second, and millisecond values)COMMA
(,
)str | String to parse |
allow_hour_overflow | Allow hour higher than 23 , but still must be 2 digits |
|
inline |
Set time of day from parsing standard time string (used internally).
HH:MM:SS
– full time of day with delimiters, but without millisecondsHH:MM
– time of day with delimiter and only hour and minuteHH
– time of day with only hour valueHHMM
– time of day with hour and minute, without delimimterHHMMSS
– full time of day without delimitersHH:MM:SS.fff
or HHMMSS.fff
– full time of day with fractional second (milliseconds)HH:MM.fff
or HHMM.fff
– full time of day with fractional minute (to give second and millisecond values)HH.fff
or HH.fff
– full time of day with fractional hour (to give minute, second, and millisecond values)COMMA
(,
)inp | Start parsing pointer (must be <= end ), set to stop position [in/out] |
end | End of string pointer, must not be NULL |
allow_hour_overflow | Allow hour higher than 23 , but still must be 2 digits |
|
inline |
Set all fields to 0, which is a valid time (midnight).
|
inline |
Set new time of day fields.
new_hour | New hour value |
new_minute | New minute value |
new_second | New second value |
new_msecond | New millisecond value |
|
inline |
Set time fields from day fraction.
msecond
is set from msec
tm | Time as a day fraction, 0.0 for midnight, 0.5 for noon, etc |
msec | Milliseconds to set (0 - 999), defaults to 0 |
|
inline |
Set to current local time of day.
|
inline |
Set to current UTC time of day.
|
inline |
Validate current time of day.
allow_hour_overflow | Allow hour higher than 23 – use get_days() to get number of days |
int hour |
Hour of day (0 - 23)
|
static |
Maximum hour value.
|
static |
Minimum hour value.
|
static |
Number of hours per day.
|
static |
Number of minutes per day.
|
static |
Number of minutes per hour.
int minute |
Minute of hour (0 - 59)
|
static |
Maximum minute value.
|
static |
Minimum minute value.
|
static |
Number of milliseconds per day.
|
static |
Number of milliseconds per hour.
|
static |
Number of milliseconds per minute.
|
static |
Number of milliseconds per second.
int msecond |
Millisecond of second (0 - 999)
|
static |
Maximum millisecond value.
|
static |
Minimum millisecond value.
|
static |
Number of seconds per day.
|
static |
Number of seconds per hour.
|
static |
Number of seconds per minute.
int second |
Second of minute (0 - 60), 60
is a special case for a leap second (rare)
|
static |
Maximum second value.
|
static |
Minimum second value.