*/
#include <common/time.h>
+#include <common/error.h>
#include <common/macros.h>
#include <stddef.h>
#include <stdint.h>
return res;
}
+LTTNG_HIDDEN
+int time_t_to_ISO8601(char *dest, size_t dest_size, time_t time)
+{
+ int ret;
+ struct tm tm, *timeinfo;
+
+ if (dest_size < ISO8601_LEN) {
+ ERR("Failed to format time to ISO8601 destination too small");
+ ret = -1;
+ goto end;
+ }
+
+ timeinfo = localtime_r(&time, &tm);
+ if (!timeinfo) {
+ PERROR("localtime");
+ ret = -1;
+ goto end;
+ }
+
+ ret = strftime(dest, dest_size, ISO8601_FORMAT, timeinfo);
+ if (ret == 0) {
+ ERR("Failed to format time to ISO8601");
+ ret = -1;
+ goto end;
+ }
+
+ ret = 0;
+end:
+ return ret;
+}
+
static
void __attribute__((constructor)) init_locale_utf8_support(void)
{