--- /dev/null
+/*
+ * Print time_t in symbolic format.
+ *
+ * Copyright (c) 2015-2017 Dmitry V. Levin <ldv@altlinux.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "tests.h"
+#include <stdio.h>
+#include <time.h>
+
+void
+print_time_t(const time_t t)
+{
+ if (!t) {
+ putchar('0');
+ return;
+ }
+
+ const struct tm *const p = localtime(&t);
+
+ if (p) {
+ char buf[256];
+
+ strftime(buf, sizeof(buf), "%FT%T%z", p);
+ fputs(buf, stdout);
+ } else {
+ printf("%llu", zero_extend_signed_to_ull(t));
+ }
+}
/* Print memory in a quoted form. */
void print_quoted_memory(const char *, size_t);
+/* Print time_t in symbolic format. */
+void print_time_t(time_t);
+
/* Read an int from the file. */
int read_int_from_file(const char *, int *);
# include <unistd.h>
# include <sys/sysmacros.h>
-static void
-print_time(const time_t t)
-{
- if (!t) {
- printf("0");
- return;
- }
-
- struct tm *p = localtime(&t);
-
- if (p) {
- char buf[256];
-
- strftime(buf, sizeof(buf), "%FT%T%z", p);
-
- printf("%s", buf);
- } else {
- printf("%llu", zero_extend_signed_to_ull(t));
- }
-}
-
# ifndef STRUCT_STAT
# define STRUCT_STAT struct stat
# define STRUCT_STAT_STR "struct stat"
# define PRINT_ST_TIME(field) \
printf(", st_" #field "="); \
- print_time(sign_extend_unsigned_to_ll(st->st_ ## field)); \
+ print_time_t(sign_extend_unsigned_to_ll(st->st_ ## field)); \
PRINT_TIME_NSEC(st->st_ ## field ## _nsec)
PRINT_ST_TIME(atime);