radarlib
1.4.6
|
Functions about times and dates. More...
Functions | |
time_t | getUTC () |
Get the current UTC time from the system. More... | |
time_t | mktime (int year, int month, int day) |
Create a time from a date. More... | |
time_t | mktime (int year, int month, int day, int hour, int min, int sec) |
Create a time from a date. More... | |
double | mktime (int year, int month, int day, int hour, int min, int sec, int msec) |
Create a time from a date. More... | |
bool | isValidDate (int year, int month, int day) |
Check if the specified date is a valid date. More... | |
bool | isValidTime (int hour, int min, int sec) |
Check if the specified time is a valid date. More... | |
void | splitYMD (time_t absolute, int &year, int &month, int &day) |
Extract date informations from a time_t value. More... | |
void | splitYMD (double absolute, int &year, int &month, int &day) |
Extract date informations from a double value. More... | |
void | splitHMS (time_t absolute, int &hour, int &min, int &sec) |
Extract day time informations from a time_t value. More... | |
void | splitHMS (double absolute, int &hour, int &min, int &sec, int &msec) |
Extract day time informations from a double value. More... | |
void | splitYMDHMS (time_t absolute, int &year, int &month, int &day, int &hour, int &min, int &sec) |
Extract date and day time informations from a time_t value. More... | |
void | splitYMDHMS (double absolute, int &year, int &month, int &day, int &hour, int &min, int &sec, int &msec) |
Extract date and day time informations from a double value. More... | |
std::string | absoluteToString (time_t value) |
, const char* fmt) More... | |
std::string | absoluteToString (double value, bool allowNAN) |
Convert an double value representing an absolute time_t value with milliseconds. More... | |
time_t | parseYYYYMMDDHHMMSS (const std::string &str) |
Convert a string to a time_t value. More... | |
time_t | toEpoch (double absolute) |
Reduce a double value to a time_t value, truncating the milliseconds. More... | |
time_t | toEpoch (float absolute) |
Reduce a float value to a time_t value, truncating the milliseconds. More... | |
time_t | extractDate (time_t absolute) |
Extract the date from a time_t value to a new time_t value. More... | |
double | extractDate (double absolute) |
Extract the date from a double value to a new double value. More... | |
time_t | extractTime (time_t absolute) |
Extract the day time from a time_t value to a new time_t value. More... | |
double | extractTime (double absolute) |
Extract the day time from a double value to a new double value. More... | |
std::string | dayTimeToStr (time_t value) |
Convert a day time to a string. More... | |
std::string | dayTimeToStr (double value) |
Convert a day time with milliseconds to a string. More... | |
void | convertYday (int year, int yday, int &month, int &day) |
Convert a year day to the corresponding month and day number. More... | |
time_t | convertYday (int year, int yday) |
Convert a year day to the corresponding time_t value. More... | |
int | mkYday (int year, int month, int day) |
Calculate the year day from a date. More... | |
Functions about times and dates.
RADAR_API time_t Radar::timeutils::getUTC | ( | ) |
Get the current UTC time from the system.
Get the current UTC time from the system as a time_t value
RADAR_API time_t Radar::timeutils::mktime | ( | int | year, |
int | month, | ||
int | day | ||
) |
Create a time from a date.
Create a time_t value from a date. The time_t value will be aligned to the hour 00:00:00 of the day specified
year | the year to use. It must be >= 1970 |
month | the month to use |
day | the day to use |
std::invalid_argument | If the date is not a valid date |
RADAR_API time_t Radar::timeutils::mktime | ( | int | year, |
int | month, | ||
int | day, | ||
int | hour, | ||
int | min, | ||
int | sec | ||
) |
Create a time from a date.
Create a time_t value from a date and a time
year | the year to use. It must be >= 1970 |
month | the month to use |
day | the day to use |
hour | the hour to use |
min | the minutes to use |
sec | the seconds to use |
std::invalid_argument | If the values are out of range |
RADAR_API double Radar::timeutils::mktime | ( | int | year, |
int | month, | ||
int | day, | ||
int | hour, | ||
int | min, | ||
int | sec, | ||
int | msec | ||
) |
Create a time from a date.
Create a time_t value from a date and a time
year | the year to use. It must be >= 1970 |
month | the month to use |
day | the day to use |
hour | the hour to use |
min | the minutes to use |
sec | the seconds to use |
msec | the milliseconds to use |
std::invalid_argument | If the values are out of range |
RADAR_API bool Radar::timeutils::isValidDate | ( | int | year, |
int | month, | ||
int | day | ||
) |
Check if the specified date is a valid date.
Check if the specified date is a valid date
year | the year to use. It must be >= 1970 |
month | the month to use |
day | the day to use |
RADAR_API bool Radar::timeutils::isValidTime | ( | int | hour, |
int | min, | ||
int | sec | ||
) |
Check if the specified time is a valid date.
Check if the specified time is a valid date
hour | the hour to use. It must be >= 1970 |
min | the min to use |
sec | the sec to use |
RADAR_API void Radar::timeutils::splitYMD | ( | time_t | absolute, |
int & | year, | ||
int & | month, | ||
int & | day | ||
) |
Extract date informations from a time_t value.
Extract date informations from the given time_t value
absolute | the absolute time_t value |
year | a reference to a integer that will store the extracted year number |
month | a reference to a integer that will store the extracted month number |
day | a reference to a integer that will store the extracted day number |
RADAR_API void Radar::timeutils::splitYMD | ( | double | absolute, |
int & | year, | ||
int & | month, | ||
int & | day | ||
) |
Extract date informations from a double value.
Extract date informations from the given double value representing an absolute time_t value with milliseconds
absolute | the absolute time_t value |
year | a reference to a integer that will store the extracted year number |
month | a reference to a integer that will store the extracted month number |
day | a reference to a integer that will store the extracted day number |
RADAR_API void Radar::timeutils::splitHMS | ( | time_t | absolute, |
int & | hour, | ||
int & | min, | ||
int & | sec | ||
) |
Extract day time informations from a time_t value.
Extract day time informations from the given time_t value
absolute | the absolute time_t value |
hour | a reference to a integer that will store the extracted hour number |
min | a reference to a integer that will store the extracted minutes number |
sec | a reference to a integer that will store the extracted seconds number |
RADAR_API void Radar::timeutils::splitHMS | ( | double | absolute, |
int & | hour, | ||
int & | min, | ||
int & | sec, | ||
int & | msec | ||
) |
Extract day time informations from a double value.
Extract day time informations from the given double value representing an absolute time_t value with milliseconds
absolute | the absolute time_t value |
hour | a reference to a integer that will store the extracted hour number |
min | a reference to a integer that will store the extracted minutes number |
sec | a reference to a integer that will store the extracted seconds number |
msec | a reference to a integer that will store the extracted milliseconds number |
RADAR_API void Radar::timeutils::splitYMDHMS | ( | time_t | absolute, |
int & | year, | ||
int & | month, | ||
int & | day, | ||
int & | hour, | ||
int & | min, | ||
int & | sec | ||
) |
Extract date and day time informations from a time_t value.
Extract date and day time informations from the given time_t value
absolute | the absolute time_t value |
year | a reference to a integer that will store the extracted hour number |
month | a reference to a integer that will store the extracted minutes number |
day | a reference to a integer that will store the extracted seconds number |
hour | a reference to a integer that will store the extracted hour number |
min | a reference to a integer that will store the extracted minutes number |
sec | a reference to a integer that will store the extracted seconds number |
RADAR_API void Radar::timeutils::splitYMDHMS | ( | double | absolute, |
int & | year, | ||
int & | month, | ||
int & | day, | ||
int & | hour, | ||
int & | min, | ||
int & | sec, | ||
int & | msec | ||
) |
Extract date and day time informations from a double value.
Extract date and day time informations from the given double value representing an absolute time_t value with milliseconds
absolute | the absolute time_t value |
year | a reference to a integer that will store the extracted hour number |
month | a reference to a integer that will store the extracted minutes number |
day | a reference to a integer that will store the extracted seconds number |
hour | a reference to a integer that will store the extracted hour number |
min | a reference to a integer that will store the extracted minutes number |
sec | a reference to a integer that will store the extracted seconds number |
msec | a reference to a integer that will store the extracted milliseconds number |
RADAR_API std::string Radar::timeutils::absoluteToString | ( | time_t | value | ) |
, const char* fmt)
Convert an absolute time_t value to a string.
Convert an absolute time_t value to a string with format 'YYYY-MM-DD hh:mm:ss'
value | the time_t value to convert |
RADAR_API std::string Radar::timeutils::absoluteToString | ( | double | value, |
bool | allowNAN | ||
) |
Convert an double value representing an absolute time_t value with milliseconds.
Convert an absolute time_t value to a string with format 'YYYY-MM-DD hh:mm:ss.msec'
value | the time_t value to convert |
allowNAN | if the value is NAN returns "0000-00-00 00:00:00" instead of throwing an exception |
std::invalid_argument | If the value cannot be converted |
RADAR_API time_t Radar::timeutils::parseYYYYMMDDHHMMSS | ( | const std::string & | str | ) |
Convert a string to a time_t value.
Convert a string to a time_t value. The string must be formated as 'YYYY-MM-DD hh:mm:ss'
str | the string to convert |
std::invalid_argument | If the string cannot be converted |
RADAR_API time_t Radar::timeutils::toEpoch | ( | double | absolute | ) |
Reduce a double value to a time_t value, truncating the milliseconds.
RADAR_API time_t Radar::timeutils::toEpoch | ( | float | absolute | ) |
Reduce a float value to a time_t value, truncating the milliseconds.
RADAR_API time_t Radar::timeutils::extractDate | ( | time_t | absolute | ) |
Extract the date from a time_t value to a new time_t value.
Extract the date from a time_t value to a new time_t value. Day time informations will be set to 00:00:00
absolute | the absolute time to use |
RADAR_API double Radar::timeutils::extractDate | ( | double | absolute | ) |
Extract the date from a double value to a new double value.
Extract the date from a double value to a new time_t value. Day time informations will be set to 00:00:00
absolute | the absolute time to use |
RADAR_API time_t Radar::timeutils::extractTime | ( | time_t | absolute | ) |
Extract the day time from a time_t value to a new time_t value.
Extract the day time from a time_t value to a new time_t value. The result value range is between 0 and 60*60*24 minutes
absolute | the absolute time to use |
RADAR_API double Radar::timeutils::extractTime | ( | double | absolute | ) |
Extract the day time from a double value to a new double value.
Extract the day time from a time_t value to a new time_t value. The result value range is between 0 and 60*60*24 minutes
absolute | the absolute time to use |
RADAR_API std::string Radar::timeutils::dayTimeToStr | ( | time_t | value | ) |
Convert a day time to a string.
Convert a day time to string formated as 'HH:MM:SS'
value | the day time as a time_t value |
RADAR_API std::string Radar::timeutils::dayTimeToStr | ( | double | value | ) |
Convert a day time with milliseconds to a string.
Convert a day time to string formated as 'HH:MM:SS.msec'
value | the day time as a double value |
RADAR_API void Radar::timeutils::convertYday | ( | int | year, |
int | yday, | ||
int & | month, | ||
int & | day | ||
) |
Convert a year day to the corresponding month and day number.
Convert a year day to the corresponding month and day number
year | the year to use |
yday | the year day to use (from 1 to 365/366) |
month | a reference to an integer that will store the month number (from 1 to 12) |
day | a reference to an integer that will store the day number (from 1 to 31) |
std::invalid_argument | if the year or yday values are not valid |
RADAR_API time_t Radar::timeutils::convertYday | ( | int | year, |
int | yday | ||
) |
Convert a year day to the corresponding time_t value.
Convert a year day to the corresponding time_t value
year | the year to use |
yday | the year day to use (from 1 to 365/366) |
std::invalid_argument | if the year or yday values are not valid |
RADAR_API int Radar::timeutils::mkYday | ( | int | year, |
int | month, | ||
int | day | ||
) |
Calculate the year day from a date.
Calculate the year day from a date
year | the year value (must be >= 1970) |
month | the month value (from 1 to 12) |
day | the day day (from 1 to 365/366) |
std::invalid_argument | if the year or yday values are not valid |