summaryrefslogtreecommitdiff
path: root/src/shared/logs-show.c
diff options
context:
space:
mode:
authorJan Synacek <jsynacek@redhat.com>2014-10-02 14:39:29 +0200
committerLennart Poettering <lennart@poettering.net>2014-10-02 14:52:32 +0200
commit9fd290443f5f99fca0dcd4216b1de70f7d3b8db1 (patch)
tree4d486eed4efd28017883e0876a92a21abe5a63ad /src/shared/logs-show.c
parentb344bcbbfda8fbe14dadc5aa4b5dfb3ced6d76e2 (diff)
journalctl: add --utc option
Introduce option to display time in UTC.
Diffstat (limited to 'src/shared/logs-show.c')
-rw-r--r--src/shared/logs-show.c8
1 files changed, 5 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) {