X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FCLIFormatter.pm;h=eff6da5832470ddfdca01e21173374a23760dd54;hp=18e408b2b7b2432884a791a1fa8c65dc68430fbb;hb=5e287f60ae597dc19c0f66bcc0e1a0785ca6eecb;hpb=57d441516345f6142e4660b4801672be2dbfe28b 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) = @_;