1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-25 05:21:30 +00:00
bramw_baserow/web-frontend/modules/database/mixins/readOnlyDateField.js
2022-09-15 08:59:42 +00:00

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)
},
},
}