yumapro
24.10-2
YumaPro SDK
|
Timestamp and time format conversion functions. More...
Macros | |
#define | TSTAMP_MIN_HEXSIZE 17 |
minimum buffer size for hex format | |
#define | TSTAMP_MIN_SIZE 29 |
normal minimum buffer size for a tstamp buffer More... | |
#define | TSTAMP_DATE_SIZE 12 |
minimum buffer size for just a date string This value MUST be the minimum size buffer used for the tstamp_datetime and tstamp_local_datetime functions | |
#define | TSTAMP_SQL_SIZE 20 |
minimum buffer size for SQL date format string | |
#define | TSTAMP_HTML_SIZE 50 |
minimum buffer size for HTML format string | |
Functions | |
void | tstamp_datetime (xmlChar *buff) |
Set the current date and time in an XML dateTime string format. More... | |
void | tstamp_highres_datetime (xmlChar *buff) |
Set the current date and time in an XML dateTime string format using highres format. More... | |
void | tstamp_local_datetime (xmlChar *buff) |
Set the current date and time in an XML dateTime string format. More... | |
void | tstamp_local_highres_datetime (xmlChar *buff) |
Set the current date and time in an XML dateTime string format using highres format. More... | |
void | tstamp_date (xmlChar *buff) |
Set the current date in an XML dateTime string format. More... | |
void | tstamp_datetime_sql (xmlChar *buff) |
Set the current date and time in an XML dateTime string format. More... | |
xmlChar * | tstamp_convert_to_utctime (const xmlChar *timestr, boolean *isNegative, status_t *res) |
Check if the specified string is a valid dateTime or date-and-time string is valid and if so, convert it to UTC time. More... | |
void | tstamp_datetime_dirname (xmlChar *buff) |
Set the current date and time in an XML dateTime string format. More... | |
void | tstamp_time2datetime (time_t *timerec, xmlChar *buff) |
Convert the specified time_t to a YANG data-and-time format. More... | |
void | tstamp_local_time2datetime (time_t *timerec, xmlChar *buff) |
Convert the specified time_t to a local time YANG date-and-time format. More... | |
status_t | tstamp_time2htmltime (time_t *timerec, xmlChar *buff, size_t buffsize) |
Convert the specified time_t to a HTML timestamp string. More... | |
status_t | tstamp_htmltime2time (const xmlChar *timestr, time_t *timerec) |
Convert the specified HTML timestamp string to time_t format. More... | |
int32 | tstamp_difftime (time_t *time1, time_t *time2) |
Compare 2 time_t structs. More... | |
void | tstamp_now (time_t *tim) |
Set the time_t to the current time. More... | |
long int | tstamp_diff (struct timeval *start_time, struct timeval *end_time, long int *usec) |
Get the elapsed time between two timeval structs. More... | |
void | tstamp_time2hex (time_t *tim, xmlChar *buf) |
Convert the time_t to a string of hex digits. More... | |
status_t | tstamp_convert_to_time (const xmlChar *timestr, time_t *rtime) |
Check if the specified string is a valid dateTime or date-and-time string is valid and if so, convert it to time_t. More... | |
time_t | tstamp_cvt_TIME (char const *time_str) |
Convert the DATE string to a time_t. More... | |
void | tstamp_highres_timenow (struct timespec *ts) |
Get the current time using a high res timestamp. More... | |
void | tstamp_set_datetime (xmlChar *buff, bool use_local) |
Set the current date and time in the buffer. More... | |
Timestamp and time format conversion functions.
NETCONF, YANG, and RESTCONF all use different date and time formats requiring conversions between them. Includes high resolution timers and monotonic clock support.
#define TSTAMP_MIN_SIZE 29 |
normal minimum buffer size for a tstamp buffer
NOTE: THIS VALUE HAS BEEN INCREASED TO HANDLE MICROSECONDS THE OLD VALUE OF 22 IS TOO SMALL FOR A HIGHRES TIMESTAMP
status_t tstamp_convert_to_time | ( | const xmlChar * | timestr, |
time_t * | rtime | ||
) |
Check if the specified string is a valid dateTime or date-and-time string is valid and if so, convert it to time_t.
timestr | pointer to buffer to check | |
[out] | rtime | pointer to return time |
xmlChar * tstamp_convert_to_utctime | ( | const xmlChar * | timestr, |
boolean * | isNegative, | ||
status_t * | res | ||
) |
Check if the specified string is a valid dateTime or date-and-time string is valid and if so, convert it to UTC time.
timestr | pointer to buffer to check | |
[out] | isNegative | address of return negative date flag
|
[out] | res | address of return status
|
time_t tstamp_cvt_TIME | ( | char const * | time_str | ) |
Convert the DATE string to a time_t.
From StackOverflow https://stackoverflow.com/questions/1765014/convert-string-from-date-into-a-time-t
time_str | DATE string |
void tstamp_date | ( | xmlChar * | buff | ) |
Set the current date in an XML dateTime string format.
[in,out] | buff | pointer to buffer to hold output
|
void tstamp_datetime | ( | xmlChar * | buff | ) |
Set the current date and time in an XML dateTime string format.
[out] | buff | pointer to buffer to hold output
|
void tstamp_datetime_dirname | ( | xmlChar * | buff | ) |
Set the current date and time in an XML dateTime string format.
[in,out] | buff | pointer to buffer to hold output
|
void tstamp_datetime_sql | ( | xmlChar * | buff | ) |
Set the current date and time in an XML dateTime string format.
[in,out] | buff | pointer to buffer to hold output
|
long int tstamp_diff | ( | struct timeval * | start_time, |
struct timeval * | end_time, | ||
long int * | usec | ||
) |
Get the elapsed time between two timeval structs.
start_time | start timestamp | |
end_time | finish timestamp | |
[out] | usec | address of return micro seconds
|
int32 tstamp_difftime | ( | time_t * | time1, |
time_t * | time2 | ||
) |
Compare 2 time_t structs.
time1 | time struct 1 |
time2 | time struct 2 |
-1 if time1 < time2 0 if time1 == time2 1 if time1 > time2
void tstamp_highres_datetime | ( | xmlChar * | buff | ) |
Set the current date and time in an XML dateTime string format using highres format.
[in,out] | buff | pointer to buffer to hold output
|
void tstamp_highres_timenow | ( | struct timespec * | ts | ) |
Get the current time using a high res timestamp.
If the make flags and system support it then the CLOCK_MONOTONIC highres clock will be used. If not then the CLOCK_REALTIME clock will be used
[out] | ts | timeres struct to fill in
|
status_t tstamp_htmltime2time | ( | const xmlChar * | timestr, |
time_t * | timerec | ||
) |
Convert the specified HTML timestamp string to time_t format.
timestr | timestamp string to convert | |
[out] | timerec | address of return time_t struct
|
void tstamp_local_datetime | ( | xmlChar * | buff | ) |
Set the current date and time in an XML dateTime string format.
[in,out] | buff | pointer to buffer to hold output
|
void tstamp_local_highres_datetime | ( | xmlChar * | buff | ) |
Set the current date and time in an XML dateTime string format using highres format.
[in,out] | buff | pointer to buffer to hold output
|
void tstamp_local_time2datetime | ( | time_t * | timerec, |
xmlChar * | buff | ||
) |
Convert the specified time_t to a local time YANG date-and-time format.
[in] | timerec | Pointer to time_t to convert. |
[in,out] | buff | Pointer to buffer to hold output.
|
void tstamp_now | ( | time_t * | tim | ) |
Set the time_t to the current time.
[out] | tim | address of time_t to set
|
void tstamp_set_datetime | ( | xmlChar * | buff, |
bool | use_local | ||
) |
Set the current date and time in the buffer.
This function allows choosing between UTC and local time based on the use_local
flag.
[in,out] | buff | Pointer to the buffer for the date and time string.
|
[in] | use_local | Boolean flag to determine if local time or UTC should be used.
|
void tstamp_time2datetime | ( | time_t * | timerec, |
xmlChar * | buff | ||
) |
Convert the specified time_t to a YANG data-and-time format.
timerec | pointer to time_t to convert | |
[in,out] | buff | pointer to buffer to hold output
|
void tstamp_time2hex | ( | time_t * | tim, |
xmlChar * | buf | ||
) |
Convert the time_t to a string of hex digits.
tim | address of time_t to use | |
[in,out] | buf | buffer to fill in
|
status_t tstamp_time2htmltime | ( | time_t * | timerec, |
xmlChar * | buff, | ||
size_t | buffsize | ||
) |
Convert the specified time_t to a HTML timestamp string.
timerec | pointer to time_t to convert | |
[in,out] | buff | pointer to buffer to hold output
|
buffsize | size of buff |