1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-24 05:03:02 +00:00
bramw_baserow/web-frontend/modules/database/mixins/readOnlyDateField.js
2021-08-11 09:30:43 +00:00

31 lines
809 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) {
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) {
return ''
}
const existing = moment.tz(value || undefined, this.getTimezone(field))
const timeFormat = getTimeMomentFormat(field.date_time_format)
return existing.format(timeFormat)
},
},
}