summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/logs-show.c8
-rw-r--r--src/shared/output-mode.h1
2 files changed, 6 insertions, 3 deletions
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 5a7bbaf03a..d5d9d090b5 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -311,8 +311,10 @@ static int output_short(
uint64_t x;
time_t t;
struct tm tm;
+ struct tm *(*gettime_r)(const time_t *, struct tm *);
r = -ENOENT;
+ gettime_r = (flags & OUTPUT_UTC) ? gmtime_r : localtime_r;
if (realtime)
r = safe_atou64(realtime, &x);
@@ -329,17 +331,17 @@ static int output_short(
switch(mode) {
case OUTPUT_SHORT_ISO:
- r = strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", localtime_r(&t, &tm));
+ r = strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", gettime_r(&t, &tm));
break;
case OUTPUT_SHORT_PRECISE:
- r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm));
+ r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", gettime_r(&t, &tm));
if (r > 0) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
".%06llu", (unsigned long long) (x % USEC_PER_SEC));
}
break;
default:
- r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm));
+ r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", gettime_r(&t, &tm));
}
if (r <= 0) {
diff --git a/src/shared/output-mode.h b/src/shared/output-mode.h
index ac1bb0123b..81d7f05d91 100644
--- a/src/shared/output-mode.h
+++ b/src/shared/output-mode.h
@@ -44,4 +44,5 @@ typedef enum OutputFlags {
OUTPUT_COLOR = 1 << 4,
OUTPUT_CATALOG = 1 << 5,
OUTPUT_BEGIN_NEWLINE = 1 << 6,
+ OUTPUT_UTC = 1 << 7,
} OutputFlags;