[pve-devel] [PATCH manager] Fix #1266: Convert Unix timestamps to milliseconds for JS Date() constructor

Dietmar Maurer dietmar at proxmox.com
Tue Jan 31 14:39:39 CET 2017


We already have a PVE.Utils.render_timestamp helper. I wonder if we should 
add a PVE.Utils.format_timestamp and call that instead?
 

> On January 31, 2017 at 2:11 PM Emmanuel Kasper <e.kasper at proxmox.com> wrote:
> 
> 
> While we're at it, use Ext.Date.format to localize the displayed dates.
> We use long day names and long month name on purpose since the date
> is displayed read only in a large window, and not sortable.
> 
> Output before the patch:
> Sun Jan 18 1970 05:37:06 GMT+0100 (CET)
> 
> Output after:
> Donnerstag 26 Januar 2017 11:29:10
> ---
>  www/manager6/qemu/Snapshot.js | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/www/manager6/qemu/Snapshot.js b/www/manager6/qemu/Snapshot.js
> index d438d68..93612b6 100644
> --- a/www/manager6/qemu/Snapshot.js
> +++ b/www/manager6/qemu/Snapshot.js
> @@ -199,7 +199,9 @@ Ext.define('PVE.window.Snapshot', {
>  		summarystore.resumeEvents();
>  		summarystore.fireEvent('refresh', summarystore);
>  
> -		form.findField('snaptime').setValue(new Date(data.snaptime));
> +		// Date() Constructor expects input in milliseconds since epoch
> +		var formattedDate = Ext.Date.format((new Date(data.snaptime * 1000)), "l d
> F Y H:i:s");
> +		form.findField('snaptime').setValue(formattedDate);
>  		form.findField('description').setValue(data.description);
>  	    }
>  	});
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



More information about the pve-devel mailing list