pinafore/src/routes/_intl/formatTimeagoDate.js

11 lines
361 B
JavaScript
Raw Normal View History

2018-11-25 18:33:59 +00:00
import { format } from '../_thirdparty/timeago/timeago'
import { mark, stop } from '../_utils/marks'
export function formatTimeagoDate (date, now) {
mark('formatTimeagoDate')
// use Math.max() to avoid things like "in 10 seconds" when the timestamps are slightly off
let res = format(date, Math.max(now, date))
stop('formatTimeagoDate')
return res
}