Browse Source

fix(nc-gui): revise copy datetime logic

pull/5602/head
Wing-Kam Wong 2 years ago
parent
commit
7b6c780c0a
  1. 13
      packages/nc-gui/composables/useMultiSelect/index.ts

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

@ -117,16 +117,21 @@ export function useMultiSelect(
} }
if (columnObj.uidt === UITypes.DateTime) { if (columnObj.uidt === UITypes.DateTime) {
let d = dayjs(textToCopy)
if (!d.isValid()) {
// e.g. textToCopy = 2023-05-06T05:12:29.000Z
// feed custom parse format
d = dayjs(textToCopy, isMysql(columnObj.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ')
}
if (isXcdbBase(meta.value?.base_id)) { if (isXcdbBase(meta.value?.base_id)) {
if (isMssql(meta.value?.base_id)) { if (isMssql(meta.value?.base_id)) {
textToCopy = dayjs(textToCopy).format(constructDateTimeFormat(columnObj)) textToCopy = d.format(constructDateTimeFormat(columnObj))
} else { } else {
textToCopy = dayjs(textToCopy).utc(true).local().format(constructDateTimeFormat(columnObj)) textToCopy = d.utc(true).local().format(constructDateTimeFormat(columnObj))
} }
} else { } else {
textToCopy = dayjs(textToCopy).format(constructDateTimeFormat(columnObj)) textToCopy = d.format(constructDateTimeFormat(columnObj))
} }
if (!dayjs(textToCopy).isValid()) { if (!dayjs(textToCopy).isValid()) {
throw new Error('Invalid Date') throw new Error('Invalid Date')
} }

Loading…
Cancel
Save