export default (context, inject) => { const leftPad2Digits = (val) => val < 10 ? '0' + val : '' + val const date = (time) => { if (!time) return const d = new Date(time * 1000) return `${1900 + d.getYear()}-` + `${leftPad2Digits(d.getMonth() + 1)}-` + `${leftPad2Digits(d.getDate())}` } const datetime = (time) => { if (!time) return const d = new Date(time * 1000) return `${date(time)}, ` + `${leftPad2Digits(d.getHours())}:` + `${leftPad2Digits(d.getMinutes())}:` + `${leftPad2Digits(d.getSeconds())}` } inject('formatter', { date, datetime, }) }