Browse Source

fix(nc-gui): revise parsing logic

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

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

@ -44,6 +44,8 @@ const dateTimeFormat = $computed(() => {
return `${dateFormat} ${timeFormat}` return `${dateFormat} ${timeFormat}`
}) })
let localModelValue = $ref(modelValue ? dayjs(modelValue).utc(true).local() : undefined)
let localState = $computed({ let localState = $computed({
get() { get() {
if (!modelValue) { if (!modelValue) {
@ -55,15 +57,11 @@ let localState = $computed({
return undefined return undefined
} }
if (isXcdbBase(column.value.base_id) && isSqlite(column.value.base_id)) { if (localModelValue) {
return /^\d+$/.test(modelValue) return localModelValue
? dayjs(+modelValue)
.utc(true)
.local()
: dayjs(modelValue).utc(true).local()
} }
return /^\d+$/.test(modelValue) ? dayjs(+modelValue) : dayjs(modelValue) return dayjs(modelValue).utc(true).local()
}, },
set(val?: dayjs.Dayjs) { set(val?: dayjs.Dayjs) {
if (!val) { if (!val) {
@ -72,7 +70,9 @@ let localState = $computed({
} }
if (val.isValid()) { if (val.isValid()) {
emit('update:modelValue', val?.format(isMysql(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ')) const formattedValue = dayjs(val?.format(isMysql(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'))
localModelValue = formattedValue
emit('update:modelValue', formattedValue)
} }
}, },
}) })

Loading…
Cancel
Save