Merge pull request #1551 from poanetwork/exact-date-and-time

(Feature) Exact date and time for Transaction details page
pull/1534/head
Victor Baranov 6 years ago committed by GitHub
commit a354b35340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      apps/block_scout_web/assets/js/lib/from_now.js

@ -19,7 +19,14 @@ function tryUpdateAge (el) {
if (timestamp.isValid()) updateAge(el, timestamp)
}
function updateAge (el, timestamp) {
const fromNow = timestamp.fromNow()
let fromNow = timestamp.fromNow()
// show the exact time only for transaction details page. Otherwise, short entry
if (window.location.pathname.startsWith('/tx/')) {
const offset = moment().utcOffset() / 60
const sign = offset && Math.sign(offset) ? '+' : '-'
const formatDate = `MMMM-DD-YYYY hh:mm:ss A ${sign}${offset} UTC`
fromNow = `${fromNow} (${timestamp.format(formatDate)})`
}
if (fromNow !== el.innerHTML) el.innerHTML = fromNow
}
updateAllAges()

Loading…
Cancel
Save