From e348c44125b6ec8f55654b1fec6982741573958e Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 22 Apr 2023 19:45:21 +0800 Subject: [PATCH] feat(nc-gui): apply new logic on xcdb base only --- .../nc-gui/components/cell/DateTimePicker.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index e430b6c854..2ed3c88a12 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -24,7 +24,7 @@ const { modelValue, isPk } = defineProps() const emit = defineEmits(['update:modelValue']) -const { isMysql, isSqlite } = useProject() +const { isMysql, isSqlite, isXcdbBase } = useProject() const { showNull } = useGlobal() @@ -55,7 +55,7 @@ let localState = $computed({ return undefined } - if (isSqlite(column.value.base_id)) { + if (isXcdbBase(column.value.base_id) && isSqlite(column.value.base_id)) { return /^\d+$/.test(modelValue) ? dayjs(+modelValue) .utc(true) @@ -72,12 +72,17 @@ let localState = $computed({ } if (val.isValid()) { - if (isMysql(column.value.base_id)) { - 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')) + if (isXcdbBase(column.value.base_id)) { + if (isMysql(column.value.base_id)) { + 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 { + emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ')) + } } else { - emit('update:modelValue', dayjs(val).utc().format('YYYY-MM-DD HH:mm:ssZ')) + // TODO(timezone): keep ext db as it is + emit('update:modelValue', val?.format(isMysql(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ')) } } },