mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-25 05:21:30 +00:00
30 lines
854 B
JavaScript
30 lines
854 B
JavaScript
import moment from '@baserow/modules/core/moment'
|
|
import {
|
|
getDateMomentFormat,
|
|
getTimeMomentFormat,
|
|
} from '@baserow/modules/database/utils/date'
|
|
|
|
export default {
|
|
methods: {
|
|
getTimezone(field) {
|
|
return field.timezone || 'UTC'
|
|
},
|
|
getDate(field, value) {
|
|
if (value === null || value === undefined) {
|
|
return ''
|
|
}
|
|
const existing = moment.tz(value || undefined, this.getTimezone(field))
|
|
const dateFormat = getDateMomentFormat(field.date_format)
|
|
return existing.format(dateFormat)
|
|
},
|
|
getTime(field, value) {
|
|
if (value === null || value === undefined) {
|
|
return ''
|
|
}
|
|
|
|
const existing = moment.tz(value || undefined, this.getTimezone(field))
|
|
const timeFormat = getTimeMomentFormat(field.date_time_format)
|
|
return existing.format(timeFormat)
|
|
},
|
|
},
|
|
}
|