2022-01-11 20:33:46 +01:00
|
|
|
|
|
|
|
|
function addZero(i) {
|
|
|
|
|
if (i < 10) {
|
|
|
|
|
i = "0" + i;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showDateDuration(start) {
|
|
|
|
|
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 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{
|
2023-08-15 12:42:40 +01:00
|
|
|
let date = addZero(start.getDate()) + "-" + addZero(start.getMonth()+1) + "-" + start.getFullYear();
|
2022-01-11 20:33:46 +01:00
|
|
|
return date;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
showDateDuration: showDateDuration
|
|
|
|
|
};
|