Browse Source

feat: added parseStringDateTime helper fn

pull/7286/head
Ramesh Mane 11 months ago
parent
commit
8590082e43
  1. 15
      packages/nocodb-sdk/src/lib/dateTimeHelper.ts

15
packages/nocodb-sdk/src/lib/dateTimeHelper.ts

@ -77,6 +77,21 @@ export function parseStringDate(v: string, dateFormat: string) {
return v; return v;
} }
export function parseStringDateTime(
v: string,
dateTimeFormat: string = `${dateFormats[0]} ${timeFormats[0]}`
) {
const dayjsObj = dayjs(v).local();
if (dayjsObj.isValid()) {
v = dayjsObj.format(dateTimeFormat);
} else {
v = dayjs(v, dateTimeFormat).local().format(dateTimeFormat);
}
return v;
}
export function convertToTargetFormat( export function convertToTargetFormat(
v: string, v: string,
oldDataFormat, oldDataFormat,

Loading…
Cancel
Save