From 71f0b6faea66e4605ab098d161fdb594aca1145e Mon Sep 17 00:00:00 2001
From: "andrey.daragan" <daragan.andrey@demlabs.net>
Date: Thu, 12 Mar 2020 15:28:13 +0000
Subject: [PATCH] Develop

---
 libdap-qt-ui-chain-wallet.qrc |  1 +
 resources/JS/TimeFunctions.js | 60 +++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 resources/JS/TimeFunctions.js

diff --git a/libdap-qt-ui-chain-wallet.qrc b/libdap-qt-ui-chain-wallet.qrc
index 5aee0596..b2b9c415 100644
--- a/libdap-qt-ui-chain-wallet.qrc
+++ b/libdap-qt-ui-chain-wallet.qrc
@@ -14,5 +14,6 @@
         <file>resources/fonts/roboto_regular.ttf</file>
         <file>resources/fonts/roboto_thin_italic.ttf</file>
         <file>resources/fonts/roboto_thin.ttf</file>
+        <file>resources/JS/TimeFunctions.js</file>
     </qresource>
 </RCC>
diff --git a/resources/JS/TimeFunctions.js b/resources/JS/TimeFunctions.js
new file mode 100644
index 00000000..6084d72e
--- /dev/null
+++ b/resources/JS/TimeFunctions.js
@@ -0,0 +1,60 @@
+//Splits a string from the log.
+function parceStringFromLog(string)
+{
+    var split = string.split(/ \[|\] \[|\]|\[/);
+    return split;
+}
+
+
+//This function converts the string representation of time to the Date format
+function parceTime(thisTime)
+{
+    var aDate = thisTime.split('-');
+    var aDay = aDate[0].split('/');
+    var aTime = aDate[1].split(':');
+    return new Date(20+aDay[2], aDay[0] - 1, aDay[1], aTime[0], aTime[1], aTime[2]);
+}
+
+
+//Returns the time in the correct form
+function getTime(thisTime)
+{
+    var tmpTime = new Date(thisTime)
+    var thisHour = tmpTime.getHours();
+    var thisMinute = tmpTime.getMinutes();
+    var thisSecond = tmpTime.getSeconds();
+    if(thisMinute < 10) thisMinute = '0' + thisMinute;
+    if(thisSecond < 10) thisSecond = '0' + thisSecond;
+    return thisHour + ':' + thisMinute + ':' + thisSecond;
+}
+
+
+//Returns the time in the correct form for the header
+function getDay(thisTime, privateDate)
+{
+    var monthArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September",
+                      "October", "November", "December"];
+    var tmpDate = new Date(thisTime);
+    var thisMonth = tmpDate.getMonth();
+    var thisDay = tmpDate.getDate();
+    var thisYear = tmpDate.getFullYear();
+
+    if(thisYear === privateDate.todayYear)
+    {
+        if(thisMonth === privateDate.todayMonth)
+        {
+            switch(thisDay)
+            {
+                case(privateDate.todayDay): return"Today";
+                case(privateDate.todayDay-1): return"Yesterday";
+                default: return monthArray[thisMonth] + ', ' + thisDay;
+            }
+        }
+        else
+            return monthArray[thisMonth] + ', ' + thisDay;
+    }
+    else
+        return monthArray[thisMonth] + ', ' + thisDay + ', ' + thisYear;
+}
+
+
-- 
GitLab