CLIFormatter - implement renderer for timestamps

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2018-07-04 13:28:27 +02:00 committed by Thomas Lamprecht
parent 57d4415163
commit 5e287f60ae

View File

@ -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) = @_;