mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-11-30 20:06:32 -05:00
move messages sidebar to own vue component
This commit is contained in:
parent
e8b4a498e3
commit
b540f20ccd
3 changed files with 258 additions and 159 deletions
|
|
@ -16,6 +16,62 @@ class Utils {
|
|||
|
||||
}
|
||||
|
||||
static parseSeconds(secondsToFormat) {
|
||||
secondsToFormat = Number(secondsToFormat);
|
||||
var days = Math.floor(secondsToFormat / (3600 * 24));
|
||||
var hours = Math.floor((secondsToFormat % (3600 * 24)) / 3600);
|
||||
var minutes = Math.floor((secondsToFormat % 3600) / 60);
|
||||
var seconds = Math.floor(secondsToFormat % 60);
|
||||
return {
|
||||
days: days,
|
||||
hours: hours,
|
||||
minutes: minutes,
|
||||
seconds: seconds,
|
||||
};
|
||||
}
|
||||
|
||||
static formatSeconds(seconds) {
|
||||
|
||||
const parsedSeconds = this.parseSeconds(seconds);
|
||||
|
||||
if(parsedSeconds.days > 0){
|
||||
if(parsedSeconds.days === 1){
|
||||
return "1 day ago";
|
||||
} else {
|
||||
return parsedSeconds.days + " days ago";
|
||||
}
|
||||
}
|
||||
|
||||
if(parsedSeconds.hours > 0){
|
||||
if(parsedSeconds.hours === 1){
|
||||
return "1 hour ago";
|
||||
} else {
|
||||
return parsedSeconds.hours + " hours ago";
|
||||
}
|
||||
}
|
||||
|
||||
if(parsedSeconds.minutes > 0){
|
||||
if(parsedSeconds.minutes === 1){
|
||||
return "a minute ago";
|
||||
} else {
|
||||
return parsedSeconds.minutes + " minutes ago";
|
||||
}
|
||||
}
|
||||
|
||||
if(parsedSeconds.seconds <= 1){
|
||||
return "a second ago";
|
||||
} else {
|
||||
return parsedSeconds.seconds + " seconds ago";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static formatTimeAgo(datetimeString) {
|
||||
const millisecondsAgo = Date.now() - new Date(datetimeString).getTime();
|
||||
const secondsAgo = Math.round(millisecondsAgo / 1000);
|
||||
return this.formatSeconds(secondsAgo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Utils;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue