yumapro  20.10-14
YumaPro SDK
Timestamp Utilities

Timestamp and time format conversion functions. More...

Collaboration diagram for Timestamp Utilities:

Macros

#define TSTAMP_MIN_HEXSIZE   17
 minimum buffer size for hex format
 
#define TSTAMP_MIN_SIZE   22
 normal minimum buffer size for a tstamp buffer
 
#define TSTAMP_DATE_SIZE   12
 minimum buffer size for just a date string
 
#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_local_datetime (xmlChar *buff)
 Set the current date and time in an XML dateTime string 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...
 
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...
 
time_t tstamp_cvt_TIME (char const *time_str)
 Convert the DATE string to a time_t. More...
 

Detailed Description

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.

Function Documentation

◆ tstamp_convert_to_utctime()

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.

Parameters
timestrpointer to buffer to check
isNegativeaddress of return negative date flag
resaddress of return status
Return values
*isNegativeTRUE if a negative dateTime string is given
FALSE if no starting '-' sign found
*resreturn status
Returns
malloced pointer to converted date time string or NULL if some error
Here is the call graph for this function:

◆ tstamp_cvt_TIME()

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

Parameters
time_strDATE string
Returns
time_t format

◆ tstamp_date()

void tstamp_date ( xmlChar *  buff)

Set the current date in an XML dateTime string format.

Parameters
buff== pointer to buffer to hold output MUST BE AT LEAST 11 CHARS
Return values
buffis filled in
Here is the caller graph for this function:

◆ tstamp_datetime()

void tstamp_datetime ( xmlChar *  buff)

Set the current date and time in an XML dateTime string format.

Parameters
buff== pointer to buffer to hold output MUST BE AT LEAST 21 CHARS
Return values
buffis filled in
Here is the caller graph for this function:

◆ tstamp_datetime_dirname()

void tstamp_datetime_dirname ( xmlChar *  buff)

Set the current date and time in an XML dateTime string format.

Parameters
buffpointer to buffer to hold output MUST BE AT LEAST 21 CHARS
Return values
buffis filled in
Here is the caller graph for this function:

◆ tstamp_datetime_sql()

void tstamp_datetime_sql ( xmlChar *  buff)

Set the current date and time in an XML dateTime string format.

Parameters
buffpointer to buffer to hold output MUST BE AT LEAST 20 CHARS
Return values
buffis filled in

◆ tstamp_diff()

long int tstamp_diff ( struct timeval *  start_time,
struct timeval *  end_time,
long int *  usec 
)

Get the elapsed time between two timeval structs.

Parameters
start_timestart timestamp
end_timefinish timestamp
usecaddress of return micro seconds
Return values
*usecnumber of micro-seconds of elapsed time
Returns
number of seconds of elapsed time

◆ tstamp_difftime()

int32 tstamp_difftime ( time_t *  time1,
time_t *  time2 
)

Compare 2 time_t structs.

Parameters
time1time struct 1
time2time struct 2
Returns
compare value
    -1 if time1 < time2
     0 if time1 == time2
     1 if time1 > time2
Here is the caller graph for this function:

◆ tstamp_htmltime2time()

status_t tstamp_htmltime2time ( const xmlChar *  timestr,
time_t *  timerec 
)

Convert the specified HTML timestamp string to time_t format.

Parameters
timestrtimestamp string to convert
timerecaddress of return time_t struct
Return values
*timerecstruct is filled in if NO_ERR
Returns
status

◆ tstamp_local_datetime()

void tstamp_local_datetime ( xmlChar *  buff)

Set the current date and time in an XML dateTime string format.

Parameters
buffpointer to buffer to hold output MUST BE AT LEAST 21 CHARS
Return values
buffis filled in
Here is the caller graph for this function:

◆ tstamp_now()

void tstamp_now ( time_t *  tim)

Set the time_t to the current time.

Parameters
timaddress of time_t to set
Return values
*timis set

◆ tstamp_time2datetime()

void tstamp_time2datetime ( time_t *  timerec,
xmlChar *  buff 
)

Convert the specified time_t to a YANG data-and-time format.

Parameters
timerecpointer to time_t to convert
buffpointer to buffer to hold output MUST BE AT LEAST 21 CHARS
Return values
buffis filled in
Here is the caller graph for this function:

◆ tstamp_time2hex()

void tstamp_time2hex ( time_t *  tim,
xmlChar *  buf 
)

Convert the time_t to a string of hex digits.

Parameters
timaddress of time_t to use
bufbuffer to fill in (MUST be at least 17 chars long) TSTAMP_MIN_HEXSIZE
Return values
bufis set to time_t converted to hex string

◆ tstamp_time2htmltime()

status_t tstamp_time2htmltime ( time_t *  timerec,
xmlChar *  buff,
size_t  buffsize 
)

Convert the specified time_t to a HTML timestamp string.

Parameters
timerecpointer to time_t to convert
buffpointer to buffer to hold output MUST BE AT LEAST 40 CHARS
buffsizesize of buff
Return values
buffis filled in
Returns
status