(d1, d2 = new Date())
| 11 | const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' }) |
| 12 | |
| 13 | const getRelativeTime = function (d1, d2 = new Date()) { |
| 14 | var elapsed = d1 - d2 |
| 15 | |
| 16 | // "Math.abs" accounts for both "past" & "future" scenarios |
| 17 | for (var u in units) |
| 18 | if (Math.abs(elapsed) > units[u] || u == 'second') |
| 19 | return rtf.format(Math.round(elapsed/units[u]), u) |
| 20 | |
| 21 | } |
| 22 | |
| 23 | export function makeLastUpdatedFriendly ( lastUpdated ) { |
| 24 |