feat(csv export): improved dates in exported CSV
Build and Push Docker image / build-and-push (push) Successful in 5m2s
Details
Build and Push Docker image / build-and-push (push) Successful in 5m2s
Details
This commit is contained in:
parent
90e30ed1ae
commit
2d59172323
|
@ -108,6 +108,16 @@ export const pprintDateRange = (d1: string | Date | Dayjs, d2: string | Date | D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format a datetime for Excel export.
|
||||||
|
* The date is formatted as "YYYY-MM-DD HH:mm:ss".
|
||||||
|
* @param date - The date string to format.
|
||||||
|
* @return {string} The formatted date.
|
||||||
|
*/
|
||||||
|
export function formatDateForExcel(date: string | Date | Dayjs): string {
|
||||||
|
return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format the duration between two dates.
|
* Format the duration between two dates.
|
||||||
* The Duration is precise to the minute.
|
* The Duration is precise to the minute.
|
||||||
|
|
|
@ -12,6 +12,7 @@ import {onlyUnique} from "@/lib/util.ts";
|
||||||
import {CSV_CHARSETS, downloadCsv} from "@/lib/csv.ts";
|
import {CSV_CHARSETS, downloadCsv} from "@/lib/csv.ts";
|
||||||
import {showSuccessNotification} from "@/components/util.tsx";
|
import {showSuccessNotification} from "@/components/util.tsx";
|
||||||
import {PocketBaseErrorAlert} from "@/lib/pocketbase.tsx";
|
import {PocketBaseErrorAlert} from "@/lib/pocketbase.tsx";
|
||||||
|
import {formatDateForExcel} from "@/lib/datetime.ts";
|
||||||
|
|
||||||
type FormValues = {
|
type FormValues = {
|
||||||
questionSchemaFields: string[]
|
questionSchemaFields: string[]
|
||||||
|
@ -121,7 +122,7 @@ export default function DownloadDataModal({opened, onClose, lists, event, query}
|
||||||
const statusData = e.entryStatusData || {}
|
const statusData = e.entryStatusData || {}
|
||||||
return [
|
return [
|
||||||
...(showDebug ? [e.user, e.id] : []),
|
...(showDebug ? [e.user, e.id] : []),
|
||||||
e.expand?.user.username ?? "N/A", e.created, e.listName, e.slotStartDate, e.slotEndDate,
|
e.expand?.user.username ?? "N/A", formatDateForExcel(e.created), e.listName, formatDateForExcel(e.slotStartDate), formatDateForExcel(e.slotEndDate),
|
||||||
...questionSchema.fields.map(f => questionData[f.id]?.value?.toString() ?? "N/A").map(escapeSeparator),
|
...questionSchema.fields.map(f => questionData[f.id]?.value?.toString() ?? "N/A").map(escapeSeparator),
|
||||||
...statusSchema.fields.map(f => statusData[f.id]?.value?.toString() ?? "N/A").map(escapeSeparator)
|
...statusSchema.fields.map(f => statusData[f.id]?.value?.toString() ?? "N/A").map(escapeSeparator)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue