[pve-devel] applied: [pve-common] CLIFormatter - implement renderer for timestamps

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jul 4 17:24:11 CEST 2018


On 7/4/18 1:28 PM, Dietmar Maurer wrote:
> Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
> ---
>  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) = @_;
>  
> 

applied




More information about the pve-devel mailing list