Browse Source

feat(nc-gui): handle sqlite datetime

pull/5601/head
Wing-Kam Wong 2 years ago
parent
commit
f451594b9f
  1. 12
      packages/nc-gui/components/cell/DateTimePicker.vue

12
packages/nc-gui/components/cell/DateTimePicker.vue

@ -24,7 +24,7 @@ const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const { isMysql } = useProject() const { isMysql, isSqlite } = useProject()
const { showNull } = useGlobal() const { showNull } = useGlobal()
@ -55,6 +55,14 @@ let localState = $computed({
return undefined return undefined
} }
if (isSqlite(column.value.base_id)) {
return /^\d+$/.test(modelValue)
? dayjs(+modelValue)
.utc(true)
.local()
: dayjs(modelValue).utc(true).local()
}
return /^\d+$/.test(modelValue) ? dayjs(+modelValue) : dayjs(modelValue) return /^\d+$/.test(modelValue) ? dayjs(+modelValue) : dayjs(modelValue)
}, },
set(val?: dayjs.Dayjs) { set(val?: dayjs.Dayjs) {
@ -66,6 +74,8 @@ let localState = $computed({
if (val.isValid()) { if (val.isValid()) {
if (isMysql(column.value.base_id)) { if (isMysql(column.value.base_id)) {
emit('update:modelValue', val?.format('YYYY-MM-DD HH:mm:ss')) emit('update:modelValue', val?.format('YYYY-MM-DD HH:mm:ss'))
} else if (isSqlite(column.value.base_id)) {
emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ss'))
} else { } else {
emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ')) emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ'))
} }

Loading…
Cancel
Save