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}`
})
let localModelValue = $ref(modelValue ? dayjs(modelValue).utc(true).local() : undefined)
let localState = $computed({
get() {
if (!modelValue) {
@ -55,15 +57,11 @@ let localState = $computed({
return undefined
}
if (isXcdbBase(column.value.base_id) && isSqlite(column.value.base_id)) {
return /^\d+$/.test(modelValue)
? dayjs(+modelValue)
.utc(true)
.local()
: dayjs(modelValue).utc(true).local()
if (localModelValue) {
return localModelValue
}
return /^\d+$/.test(modelValue) ? dayjs(+modelValue) : dayjs(modelValue)
return dayjs(modelValue).utc(true).local()
},
set(val?: dayjs.Dayjs) {
if (!val) {
@ -72,7 +70,9 @@ let localState = $computed({
}
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