1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-03-14 04:32:50 +00:00
bramw_baserow/web-frontend/modules/database/mixins/readOnlyDateField.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-08-11 07:39:58 +00:00
import {
getDateMomentFormat,
getTimeMomentFormat,
getCellTimezoneAbbr,
getFieldTimezone,
2021-08-11 07:39:58 +00:00
} from '@baserow/modules/database/utils/date'
import moment from '@baserow/modules/core/moment'
2021-08-11 07:39:58 +00:00
export default {
methods: {
getDate(field, value) {
2022-09-15 08:59:42 +00:00
if (value === null || value === undefined) {
2021-08-11 07:39:58 +00:00
return ''
}
const timezone = getFieldTimezone(field)
2023-03-28 16:19:25 +00:00
const existing = moment.utc(value, moment.ISO_8601, true)
if (timezone) {
2023-03-28 16:19:25 +00:00
existing.tz(timezone)
}
2021-08-11 07:39:58 +00:00
const dateFormat = getDateMomentFormat(field.date_format)
return existing.format(dateFormat)
},
getTime(field, value) {
2022-09-15 08:59:42 +00:00
if (value === null || value === undefined) {
2021-08-11 07:39:58 +00:00
return ''
}
const timezone = getFieldTimezone(field)
2023-03-28 16:19:25 +00:00
const existing = moment.utc(value, moment.ISO_8601, true)
if (timezone) {
2023-03-28 16:19:25 +00:00
existing.tz(timezone)
}
2021-08-11 07:39:58 +00:00
const timeFormat = getTimeMomentFormat(field.date_time_format)
return existing.format(timeFormat)
},
getCellTimezoneAbbr(field, value) {
return getCellTimezoneAbbr(field, value)
},
2021-08-11 07:39:58 +00:00
},
}