1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-21 23:37:55 +00:00
bramw_baserow/web-frontend/modules/database/mixins/readOnlyDateField.js
Davide Silvestri 80bce5219b Timezone fix
2023-03-28 16:19:25 +00:00

44 lines
1.1 KiB
JavaScript

import {
getDateMomentFormat,
getTimeMomentFormat,
getCellTimezoneAbbr,
getFieldTimezone,
} from '@baserow/modules/database/utils/date'
import moment from '@baserow/modules/core/moment'
export default {
methods: {
getDate(field, value) {
if (value === null || value === undefined) {
return ''
}
const timezone = getFieldTimezone(field)
const existing = moment.utc(value, moment.ISO_8601, true)
if (timezone) {
existing.tz(timezone)
}
const dateFormat = getDateMomentFormat(field.date_format)
return existing.format(dateFormat)
},
getTime(field, value) {
if (value === null || value === undefined) {
return ''
}
const timezone = getFieldTimezone(field)
const existing = moment.utc(value, moment.ISO_8601, true)
if (timezone) {
existing.tz(timezone)
}
const timeFormat = getTimeMomentFormat(field.date_time_format)
return existing.format(timeFormat)
},
getCellTimezoneAbbr(field, value) {
return getCellTimezoneAbbr(field, value)
},
},
}