mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
switch temporal manipulations to momentjs
use exact same version as handsontable
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
<template>
|
||||
<span class="utc-time" v-if="mode == 'date'" :title="elapsedTime">
|
||||
{{ date }}
|
||||
{{ full_date }}
|
||||
</span>
|
||||
<span class="utc-time utc-time-elapsed" v-else :title="date">
|
||||
<span class="utc-time utc-time-elapsed" v-else :title="full_date">
|
||||
{{ elapsedTime }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from "moment";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
date: {
|
||||
@@ -21,30 +23,10 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
elapsedTime: function() {
|
||||
var utcUpdate = new Date(this.date);
|
||||
var now = new Date();
|
||||
var utcNow = new Date(
|
||||
now.getUTCFullYear(),
|
||||
now.getUTCMonth(),
|
||||
now.getUTCDate(),
|
||||
now.getUTCHours(),
|
||||
now.getUTCMinutes(),
|
||||
now.getUTCSeconds(),
|
||||
now.getUTCMilliseconds()
|
||||
);
|
||||
const timeDiff = utcNow - utcUpdate;
|
||||
const daysDiff = timeDiff / (1000 * 3600 * 24);
|
||||
const hoursDiff = timeDiff / (1000 * 3600);
|
||||
const minutesDiff = timeDiff / (1000 * 60);
|
||||
let diffStr;
|
||||
if (daysDiff >= 1) {
|
||||
diffStr = `${Math.floor(daysDiff)} days ago`;
|
||||
} else if (hoursDiff >= 1) {
|
||||
diffStr = `${Math.floor(hoursDiff)} hours ago`;
|
||||
} else {
|
||||
diffStr = `${Math.floor(minutesDiff)} minutes ago`;
|
||||
}
|
||||
return diffStr;
|
||||
return moment(moment.utc(this.date)).from(moment().utc());
|
||||
},
|
||||
full_date: function() {
|
||||
return moment.utc(this.date).format();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
"latex-parser": "^0.6.2",
|
||||
"latex-to-unicode-converter": "^0.5.2",
|
||||
"markdown-it": "^8.4.2",
|
||||
"moment": "2.20.1",
|
||||
"popper.js": "^1.14.7",
|
||||
"pyre-to-regexp": "^0.0.5",
|
||||
"raven-js": "^3.27.0",
|
||||
|
||||
Reference in New Issue
Block a user