From 5bb7dfce7db7d4d3a9b97f8924313c139ab4dc7f Mon Sep 17 00:00:00 2001 From: Lennart Blom Date: Sat, 1 Dec 2018 20:32:33 +0100 Subject: [PATCH] Optimize date format --- src/tags/tag-history.tag | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/tags/tag-history.tag b/src/tags/tag-history.tag index 9d396ea..e2965db 100644 --- a/src/tags/tag-history.tag +++ b/src/tags/tag-history.tag @@ -51,20 +51,49 @@ along with this program. If not, see . oReq.addEventListener('load', function () { console.log("taghistory addEventListener::load"); registryUI.taghistory.elements = []; + + function modifySpecificAttributeTypes(value) { + if (attribute == "created") { + let date = new Date(value); + let year = date.getFullYear(); + let month = date.getMonth(); + let day = date.getDay(); + let minutes = date.getMinutes(); + let hours = date.getUTCHours(); + let seconds = date.getSeconds(); + let milliSeconds = date.getMilliseconds(); + + if (month < 10) { + month = '0' + month; + } + + if (minutes < 10) { + minutes = '0' + minutes; + } + if (hours < 10) { + hours = '0' + hours; + } + + value = day + "." + month + "." + year+ " | " + hours + ":" + minutes + ":" + seconds + "." + milliSeconds; + } else if (attribute == "container_config" || attribute == "config") { + value = ""; + } + return value; + } + if (this.status == 200) { var elements = JSON.parse(this.responseText).history || []; for(var index in elements){ var parsedNestedElements = JSON.parse(elements[index].v1Compatibility || {}); + var guiElements = []; var guiElement = {}; + for(var attribute in parsedNestedElements){ if(parsedNestedElements.hasOwnProperty(attribute)){ var value = parsedNestedElements[attribute]; - if(attribute == "created"){ - // Todo this must be parsed correctly - }else if(attribute == "container_config" || attribute == "config"){ - value = ""; - } + + value = modifySpecificAttributeTypes(value); guiElement = { "key": attribute, "value": value