diff --git a/libdap-qt-ui-chain-wallet.qrc b/libdap-qt-ui-chain-wallet.qrc index 5aee0596244e02842a31830ff8a07702e11e6b91..b2b9c41577e45739344bda0d1c3bce150c789335 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 0000000000000000000000000000000000000000..6084d72e283b92184ab0a05e5f7b35ba9441ba70 --- /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; +} + +