From 5e287f60ae597dc19c0f66bcc0e1a0785ca6eecb Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 4 Jul 2018 13:28:27 +0200 Subject: [PATCH] CLIFormatter - implement renderer for timestamps Signed-off-by: Dietmar Maurer --- src/PVE/CLIFormatter.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm index 18e408b..eff6da5 100644 --- a/src/PVE/CLIFormatter.pm +++ b/src/PVE/CLIFormatter.pm @@ -3,6 +3,7 @@ package PVE::CLIFormatter; use strict; use warnings; use I18N::Langinfo; +use POSIX qw(strftime); use PVE::JSONSchema; use PVE::PTY; @@ -10,6 +11,15 @@ use JSON; use utf8; use Encode; +sub render_timestamp { + my ($epoch) = @_; + + # ISO 8601 date format + return strftime("%F %H:%M:%S", localtime($epoch)); +} + +PVE::JSONSchema::register_renderer('timestamp', \&render_timestamp); + sub render_duration { my ($duration_in_seconds) = @_; -- 2.39.2