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

Emmanuel Kasper e.kasper at proxmox.com
Tue Jan 31 14:11:07 CET 2017


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





More information about the pve-devel mailing list