Merge with chat/labe branch and display time on chat message baloom

This commit is contained in:
Eudes Inácio
2023-09-12 12:27:02 +01:00
35 changed files with 664 additions and 207 deletions
+29 -27
View File
@@ -1,4 +1,3 @@
function addZero(i) {
if (i < 10) {
i = "0" + i;
@@ -7,36 +6,39 @@ function addZero(i) {
}
function showDateDuration(start) {
let end;
end = new Date();
start = new Date(start);
let customizedDate;
let end;
end = new Date();
start = new Date(start);
let customizedDate;
const totalSeconds = Math.floor((end - start) / 1000);
const totalMinutes = Math.floor(totalSeconds / 60);
const totalHours = Math.floor(totalMinutes / 60);
const totalDays = Math.floor(totalHours / 24);
const totalSeconds = Math.floor((end - (start))/1000);;
const totalMinutes = Math.floor(totalSeconds/60);
const totalHours = Math.floor(totalMinutes/60);
const totalDays = Math.floor(totalHours/24);
const hours = totalHours - totalDays * 24;
const minutes = totalMinutes - totalDays * 24 * 60 - hours * 60;
const seconds =
totalSeconds - totalDays * 24 * 60 * 60 - hours * 60 * 60 - minutes * 60;
const hours = totalHours - ( totalDays * 24 );
const minutes = totalMinutes - ( totalDays * 24 * 60 ) - ( hours * 60 );
const seconds = totalSeconds - ( totalDays * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 );
if(totalDays == 0){
if(start.getDate() == new Date().getDate()){
let time = start.getHours() + ":" + addZero(start.getUTCMinutes());
return time;
}
else{
return 'Ontem';
}
}
else{
let date = addZero(start.getDate()) + "-" + addZero(start.getMonth()+1) + "-" + start.getFullYear();
return date;
let time = start.getHours() + ":" + addZero(start.getUTCMinutes());
if (totalDays == 0) {
if (start.getDate() == new Date().getDate()) {
return time;
} else {
return time;
}
} else {
let date =
addZero(start.getDate()) +
"-" +
addZero(start.getMonth() + 1) +
"-" +
start.getFullYear();
return date;
}
}
module.exports = {
showDateDuration: showDateDuration
};
showDateDuration: showDateDuration,
};