timestamp.h

    #include <mplib1/timestamp.h>

make_timestamp_str

    char * make_timestamp_str( char *buffer );
The make_timestamp_str function generates a timestamp string from the current time from the build_timestamp_str function. formatted to ISO 8601 / EN28601 based on the current time.

The timestamp is in UTC and is formed using strftime() and then adding hundredths of seconds and timezone offset.

The buffer parameter specifies a data area in which to create this string. If it is provided it should be at least 24 characters long. If the buffer parameter is NULL then the routine uses an internal static buffer, the resultant value should be used immediately or copied. An example of the completed string is;

    "1996-12-31 13:45:56.78Z"
This function is implemented using the following two functions.


build_timestamp_str

    char *build_timestamp_str( struct timeval *tvp, char *buf );
This function function generates a timestamp string formatted to ISO 8601 / EN28601 based on the supplied timeval structure.

The timestamp is in UTC and is formed using strftime() and then adding hundredths of seconds and timezone offset.

The buffer parameter specifies a data area in which to create this string. If it is provided it should be at least 24 characters long. If the buffer parameter is NULL then the routine uses an internal static buffer, the resultant value should be used immediately or copied. An example of the completed string is;

    "1996-12-31 13:45:56.78Z"


get_current_timeval

    struct timeval *get_current_timeval( struct timeval * );
This function gets the current time of day in UTC using the system gettimeofday function. It is provided as a platform independant variation of the system call because it varies between implementations.

Revision note.

As of library version 2.5.0 the build_timestamp_str function produces a string conforming to ISO 8601 / EN28601. Previously the format was YYYY/MM/DD HH:MM:SS:DD which was a little confusing. The new string is one character longer, but does not cause any buffer to be overwritten if they were specified as being at least 24 characters long.