+
+std::string lttng::utils::time_to_iso8601_str(std::time_t time)
+{
+ std::string iso8601_str(ISO8601_STR_LEN, '\0');
+ const auto ret = ::time_to_iso8601_str(time, &iso8601_str[0], iso8601_str.capacity());
+
+ if (ret) {
+ LTTNG_THROW_ERROR("Failed to format time to iso8601 format");
+ }
+
+ /* Don't include '\0' in the C++ string. */
+ iso8601_str.resize(iso8601_str.size() - 1);
+
+ return iso8601_str;
+}