Browse Source

fix(nc-gui): revise mysql xcdb & ext logic

pull/5642/head
Wing-Kam Wong 2 years ago
parent
commit
ad2ec7d128
  1. 25
      packages/nc-gui/composables/useMultiSelect/convertCellData.ts
  2. 9
      packages/nc-gui/composables/useMultiSelect/index.ts

25
packages/nc-gui/composables/useMultiSelect/convertCellData.ts

@ -39,33 +39,10 @@ export default function convertCellData(
return parsedDate.format('YYYY-MM-DD')
}
case UITypes.DateTime: {
let parsedDateTime = dayjs(value)
const parsedDateTime = dayjs(value)
if (!parsedDateTime.isValid()) {
throw new Error('Not a valid datetime value')
}
if (isMysql && !dayjs.isDayjs(value)) {
if (value.indexOf('+') === -1) {
// insert a datatime cell -> copy and paste -> copy again -> paste
// e.g. value = 2023-05-12 08:06:54
if (value.slice(-1) !== 'Z') {
// e.g. 2023-05-11 12:00:00 -> 2023-05-11 12:00:00Z0
parsedDateTime = dayjs(value + 'Z')
}
}
}
if (isXcdbBase) {
// convert back to utc
// e.g. (mysql) 2023-05-11 12:00:00+00:00 -> 2023-05-11 12:00:00
// e.g. 2023-05-09T19:41:49+08:00 -> 2023-05-09 11:41:49
return parsedDateTime.utc().format(isMysql ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ')
}
// External DB
if (isMysql) {
// convert back to utc
return parsedDateTime.utc().format('YYYY-MM-DD HH:mm:ss')
}
return parsedDateTime.format('YYYY-MM-DD HH:mm:ssZ')
}
case UITypes.Time: {

9
packages/nc-gui/composables/useMultiSelect/index.ts

@ -130,15 +130,6 @@ export function useMultiSelect(
textToCopy = textToCopy.replace(/["']/g, '')
const isMySQL = isMysql(columnObj.base_id)
if (isMySQL) {
if (textToCopy.indexOf('+') === -1) {
// insert a datatime cell -> copy and paste -> copy again
if (textToCopy.slice(-1) !== 'Z') {
// e.g. 2023-05-11 12:00:00 -> 2023-05-11 12:00:00Z
textToCopy += 'Z'
}
}
}
let d = dayjs(textToCopy)

Loading…
Cancel
Save