timestamp formatting vue component
This commit is contained in:
parent
6ecdbda9fa
commit
0cf81f3a5b
21
js/components/local_datetime.js
Normal file
21
js/components/local_datetime.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { format } from 'date-fns'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'local-datetime',
|
||||||
|
|
||||||
|
props: {
|
||||||
|
timestamp: String,
|
||||||
|
format: {
|
||||||
|
type: String,
|
||||||
|
default: 'MMM D YYYY H:mm'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
displayTime: function () {
|
||||||
|
return format(this.timestamp, this.format)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
template: '<time v-bind:datetime="timestamp">{{ this.displayTime }}</time>'
|
||||||
|
}
|
@ -17,6 +17,7 @@ import Modal from './mixins/modal'
|
|||||||
import selector from './components/selector'
|
import selector from './components/selector'
|
||||||
import BudgetChart from './components/charts/budget_chart'
|
import BudgetChart from './components/charts/budget_chart'
|
||||||
import CcpoApproval from './components/forms/ccpo_approval'
|
import CcpoApproval from './components/forms/ccpo_approval'
|
||||||
|
import LocalDatetime from './components/local_datetime'
|
||||||
|
|
||||||
Vue.use(VTooltip)
|
Vue.use(VTooltip)
|
||||||
|
|
||||||
@ -35,7 +36,8 @@ const app = new Vue({
|
|||||||
NewProject,
|
NewProject,
|
||||||
selector,
|
selector,
|
||||||
BudgetChart,
|
BudgetChart,
|
||||||
CcpoApproval
|
CcpoApproval,
|
||||||
|
LocalDatetime
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
const modalOpen = document.querySelector("#modalOpen")
|
const modalOpen = document.querySelector("#modalOpen")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user