diff --git a/src/components/nodes/NodesList.vue b/src/components/nodes/NodesList.vue
index 2b7385b..3c3dd26 100644
--- a/src/components/nodes/NodesList.vue
+++ b/src/components/nodes/NodesList.vue
@@ -24,16 +24,29 @@
-
+
-
-
Unknown Hops
-
Direct Connection
-
1 Hop Away
-
{{ node.hopsAway }} Hops Away
+
+
+
-
• heard {{ formatUnixSecondsAgo(node.lastHeard) }}
+
+ {{ formatUnixSecondsAgo(node.lastHeard) }}
+
+
+
+
+ •
+ ???
+ Direct
+ 1 Hop
+ {{ node.hopsAway }} Hops
+
@@ -55,6 +68,7 @@ import moment from "moment";
import NodeIcon from "./NodeIcon.vue";
import GlobalState from "../../js/GlobalState.js";
import NodeDropDownMenu from "./NodeDropDownMenu.vue";
+import TimeUtils from "../../js/TimeUtils.js";
export default {
name: 'NodesList',
@@ -84,7 +98,7 @@ export default {
getNodeColour: (nodeId) => NodeUtils.getNodeColour(nodeId),
getNodeTextColour: (nodeId) => NodeUtils.getNodeTextColour(nodeId),
formatUnixSecondsAgo(unixSeconds) {
- return moment.unix(unixSeconds).fromNow();
+ return TimeUtils.getTimeAgoShortHand(moment.unix(unixSeconds).toDate());
},
},
computed: {
diff --git a/src/js/TimeUtils.js b/src/js/TimeUtils.js
new file mode 100644
index 0000000..234022a
--- /dev/null
+++ b/src/js/TimeUtils.js
@@ -0,0 +1,52 @@
+import moment from "moment";
+
+class TimeUtils {
+
+ static getTimeAgoShortHand(date) {
+
+ // get duration between now and provided date
+ const duration = moment.duration(moment().diff(date));
+
+ // years
+ const years = Math.floor(duration.asYears());
+ if(years > 0){
+ return `${years} ${years === 1 ? 'year' : 'years'} ago`;
+ }
+
+ // months
+ const months = Math.floor(duration.asMonths());
+ if(months > 0){
+ return `${months} ${months === 1 ? 'month' : 'months'} ago`;
+ }
+
+ // weeks
+ const weeks = Math.floor(duration.asWeeks());
+ if(weeks > 0){
+ return `${weeks} ${weeks === 1 ? 'week' : 'weeks'} ago`;
+ }
+
+ // days
+ const days = Math.floor(duration.asDays());
+ if(days > 0){
+ return `${days} ${days === 1 ? 'day' : 'days'} ago`;
+ }
+
+ // hours
+ const hours = Math.floor(duration.asHours());
+ if(hours > 0){
+ return `${hours} ${hours === 1 ? 'hour' : 'hours'} ago`;
+ }
+
+ // minutes
+ const minutes = Math.floor(duration.asMinutes());
+ if(minutes > 0){
+ return `${minutes} ${minutes === 1 ? 'min' : 'mins'} ago`;
+ }
+
+ return "now";
+
+ };
+
+}
+
+export default TimeUtils;