From 1a0b410554af31b60dd192677656a4b811eb3281 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 14 Jan 2021 13:59:08 +0100 Subject: [PATCH] manager: user/token list: fix rendering 0 (never) expire date Signed-off-by: Thomas Lamprecht --- src/bin/proxmox_backup_manager/user.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/bin/proxmox_backup_manager/user.rs b/src/bin/proxmox_backup_manager/user.rs index 8d78b08c..d68e9e81 100644 --- a/src/bin/proxmox_backup_manager/user.rs +++ b/src/bin/proxmox_backup_manager/user.rs @@ -10,6 +10,23 @@ use proxmox_backup::tools; use proxmox_backup::api2; use proxmox_backup::api2::types::{ACL_PATH_SCHEMA, Authid, Userid}; +fn render_expire(value: &Value, _record: &Value) -> Result { + let never = String::from("never"); + if value.is_null() { return Ok(never); } + let text = match value.as_i64() { + Some(epoch) if epoch == 0 => never, + Some(epoch) => { + if let Ok(epoch_string) = proxmox::tools::time::strftime_local("%c", epoch as i64) { + epoch_string + } else { + epoch.to_string() + } + }, + None => value.to_string(), + }; + Ok(text) +} + #[api( input: { properties: { @@ -39,7 +56,7 @@ fn list_users(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result Result