Formatting functions
***********************************************************************/
-static const char utc_zone[] = "+00:00";
static const char zulu_zone[] = "Z";
/* format_zone reads time zone information from "extern long timezone", exported
return 0;
} /* }}} int format_rfc3339 */
-int format_rfc3339_utc (char *buffer, size_t buffer_size, cdtime_t t, _Bool print_nano, char const *zone) /* {{{ */
+int format_rfc3339_utc (char *buffer, size_t buffer_size, cdtime_t t, _Bool print_nano) /* {{{ */
{
struct tm t_tm;
- long nsec;
+ long nsec = 0;
int status;
if ((status = get_utc_time (t, &t_tm, &nsec)) != 0)
return status; /* The error should have already be reported. */
- return format_rfc3339 (buffer, buffer_size, &t_tm, nsec, print_nano, zone);
+ return format_rfc3339 (buffer, buffer_size, &t_tm, nsec, print_nano, zulu_zone);
} /* }}} int format_rfc3339_utc */
int format_rfc3339_local (char *buffer, size_t buffer_size, cdtime_t t, _Bool print_nano) /* {{{ */
{
struct tm t_tm;
- long nsec;
+ long nsec = 0;
int status;
char zone[7]; /* +00:00 */
if (buffer_size < RFC3339_SIZE)
return ENOMEM;
- return format_rfc3339_utc (buffer, buffer_size, t, 0, utc_zone);
+ return format_rfc3339_utc (buffer, buffer_size, t, 0);
} /* }}} int rfc3339 */
int rfc3339nano (char *buffer, size_t buffer_size, cdtime_t t) /* {{{ */
if (buffer_size < RFC3339NANO_SIZE)
return ENOMEM;
- return format_rfc3339_utc (buffer, buffer_size, t, 1, utc_zone);
+ return format_rfc3339_utc (buffer, buffer_size, t, 1);
} /* }}} int rfc3339nano */
-int rfc3339_zulu (char *buffer, size_t buffer_size, cdtime_t t) /* {{{ */
-{
- if (buffer_size < RFC3339_ZULU_SIZE)
- return ENOMEM;
-
- return format_rfc3339_utc (buffer, buffer_size, t, 0, zulu_zone);
-} /* }}} int rfc3339_zulu */
-
-int rfc3339nano_zulu (char *buffer, size_t buffer_size, cdtime_t t) /* {{{ */
-{
- if (buffer_size < RFC3339NANO_ZULU_SIZE)
- return ENOMEM;
-
- return format_rfc3339_utc (buffer, buffer_size, t, 1, zulu_zone);
-} /* }}} int rfc3339nano_zulu */
-
int rfc3339_local (char *buffer, size_t buffer_size, cdtime_t t) /* {{{ */
{
if (buffer_size < RFC3339_SIZE)
#define RFC3339_SIZE 26 /* 2006-01-02T15:04:05+00:00 */
#define RFC3339NANO_SIZE 36 /* 2006-01-02T15:04:05.999999999+00:00 */
-#define RFC3339_ZULU_SIZE 21 /* 2006-01-02T15:04:05Z */
-#define RFC3339NANO_ZULU_SIZE 31 /* 2006-01-02T15:04:05.999999999Z */
-
-/* rfc3339 formats a cdtime_t time as UTC in RFC 3339 format with second
- * precision. */
+/* rfc3339 formats a cdtime_t time as UTC in RFC 3339 zulu format with second
+ * precision, e.g., "2006-01-02T15:04:05Z". */
int rfc3339 (char *buffer, size_t buffer_size, cdtime_t t);
-/* rfc3339nano formats a cdtime_t as UTC time in RFC 3339 format with
- * nanosecond precision. */
+/* rfc3339nano formats a cdtime_t as UTC time in RFC 3339 zulu format with
+ * nanosecond precision, e.g., "2006-01-02T15:04:05.999999999Z". */
int rfc3339nano (char *buffer, size_t buffer_size, cdtime_t t);
-/* rfc3339 formats a cdtime_t time as UTC in RFC 3339 zulu format with second
- * precision. */
-int rfc3339_zulu (char *buffer, size_t buffer_size, cdtime_t t);
-
-/* rfc3339nano formats a cdtime_t time as UTC in RFC 3339 zulu format with
- * nanosecond precision. */
-int rfc3339nano_zulu (char *buffer, size_t buffer_size, cdtime_t t);
-
/* rfc3339 formats a cdtime_t time as local in RFC 3339 format with second
- * precision. */
+ * precision, e.g., "2006-01-02T15:04:05+00:00". */
int rfc3339_local (char *buffer, size_t buffer_size, cdtime_t t);
/* rfc3339nano formats a cdtime_t time as local in RFC 3339 format with
- * nanosecond precision. */
+ * nanosecond precision, e.g., "2006-01-02T15:04:05.999999999+00:00". */
int rfc3339nano_local (char *buffer, size_t buffer_size, cdtime_t t);
#endif /* UTILS_TIME_H */