X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdaemon%2Futils_time.h;h=9e98040694eb8b57822653e6fc1df5296646a314;hb=40aabf444e124f40603021821e98bcc40c4aaa0e;hp=6566a739bdf8be34b695a3d715dd90b7644e2f23;hpb=598a534ab6f2d122556434b82818c4b6ed8e48f9;p=collectd.git diff --git a/src/daemon/utils_time.h b/src/daemon/utils_time.h index 6566a739..9e980406 100644 --- a/src/daemon/utils_time.h +++ b/src/daemon/utils_time.h @@ -29,6 +29,12 @@ #include "collectd.h" +#ifdef TESTING_H +/* cdtime_mock is the time returned by cdtime() when build with + * -DMOCK_TIME */ +extern cdtime_t cdtime_mock; +#endif + /* * "cdtime_t" is a 64bit unsigned integer. The time is stored at a 2^-30 second * resolution, i.e. the most significant 34 bit are used to store the time in @@ -76,11 +82,15 @@ cdtime_t cdtime (void); -/* format a cdtime_t value in ISO 8601 format: - * returns the number of characters written to the string (not including the - * terminating null byte or 0 on error; the function ensures that the string - * is null terminated */ -size_t cdtime_to_iso8601 (char *s, size_t max, cdtime_t t); +#define RFC3339_SIZE 26 +#define RFC3339NANO_SIZE 36 + +/* rfc3339 formats a cdtime_t time in RFC 3339 format with second precision. */ +int rfc3339 (char *buffer, size_t buffer_size, cdtime_t t); + +/* rfc3339nano formats a cdtime_t time in RFC 3339 format with nanosecond + * precision. */ +int rfc3339nano (char *buffer, size_t buffer_size, cdtime_t t); #endif /* UTILS_TIME_H */ /* vim: set sw=2 sts=2 et : */