1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-19 19:43:16 +00:00
bramw_baserow/web-frontend/modules/database/components/view/grid/fields/FunctionalGridViewFieldDate.vue

51 lines
1.3 KiB
Vue

<template functional>
<div ref="cell" class="grid-view__cell">
<div
class="grid-field-date"
:class="{ 'grid-field-date--has-time': props.field.date_include_time }"
>
<div ref="dateDisplay" class="grid-field-date__date">
{{ $options.methods.getDate(props.field, props.value) }}
</div>
<div
v-if="props.field.date_include_time"
ref="timeDisplay"
class="grid-field-date__time"
>
{{ $options.methods.getTime(props.field, props.value) }}
</div>
</div>
</div>
</template>
<script>
import moment from 'moment'
import {
getDateMomentFormat,
getTimeMomentFormat,
} from '@baserow/modules/database/utils/date'
export default {
name: 'FunctionalGridViewFieldDate',
methods: {
getDate(field, value) {
if (value === null) {
return ''
}
const existing = moment.utc(value || undefined)
const dateFormat = getDateMomentFormat(field.date_format)
return existing.format(dateFormat)
},
getTime(field, value) {
if (value === null) {
return ''
}
const existing = moment.utc(value || undefined)
const timeFormat = getTimeMomentFormat(field.date_time_format)
return existing.format(timeFormat)
},
},
}
</script>