}
#pragma GCC diagnostic pop
+int __pakfire_timeval_to_iso8601(char* buffer, const size_t length, const struct timeval* t) {
+ struct tm tm = {};
+
+ // Convert to broken down time
+ if (!gmtime_r(&t->tv_sec, &tm))
+ return -errno;
+
+ return __pakfire_string_format(buffer, length, "%04d-%02d-%02dT%02d:%02d:%02d.%03ldZ",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
+ US_TO_MS(t->tv_usec));
+}
+
char* pakfire_string_format_interval(const time_t t) {
char* buffer = NULL;
int r;
__pakfire_format_time(buffer, sizeof(buffer), t)
int __pakfire_format_time(char* buffer, const size_t length, const time_t t);
+#define pakfire_timeval_to_iso8601(buffer, t) \
+ __pakfire_timeval_to_iso8601(buffer, sizeof(buffer), t)
+int __pakfire_timeval_to_iso8601(char* buffer, const size_t length, const struct timeval* t);
+
size_t pakfire_string_parse_bytes(const char* s);
char* pakfire_string_format_interval(const time_t t);
#define US_TO_S(s) (s / 1000000)
#define NS_TO_S(s) (s / 1000000000)
+#define US_TO_MS(us) (us / 1000)
+
static inline double pakfire_timespec_delta(struct timespec* t1, struct timespec* t2) {
// Compute delta in seconds
return (