Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit fb1052d

Browse files
committed
parse date correctly
1 parent 737ecea commit fb1052d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/components/tableActions/ExportCsvAction.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { t } from "lang/helpers";
44
import { RowDataType } from "cdm/FolderModel";
55
import { CsvHeaders } from "cdm/ServicesModel";
66
import { CsvParserService } from "services/csv/CsvParserService";
7+
import { ParseService } from "services/ParseService";
8+
import { InputType } from "helpers/Constants";
9+
import { CustomView } from "views/AbstractView";
10+
import { Literal } from "obsidian-dataview";
711

812
const ExportCsvAction = (actionProps: TableActionProps) => {
913
const { table } = actionProps;
@@ -22,7 +26,7 @@ const ExportCsvAction = (actionProps: TableActionProps) => {
2226
table.getRowModel().rows
2327
);
2428

25-
exportToCsv(`${view.diskConfig.yaml.name}.csv`, csvRows, csvHeaders);
29+
exportToCsv(`${view.diskConfig.yaml.name}.csv`, csvRows, csvHeaders, view);
2630
};
2731

2832
const handleCsvDownload = (e: MouseEvent) => {
@@ -52,7 +56,8 @@ const ExportCsvAction = (actionProps: TableActionProps) => {
5256
export const exportToCsv = (
5357
filename: string,
5458
rows: RowDataType[],
55-
headers: CsvHeaders[]
59+
headers: CsvHeaders[],
60+
view: CustomView
5661
): void => {
5762
if (!rows || !rows.length) {
5863
return;
@@ -72,12 +77,13 @@ export const exportToCsv = (
7277
.map((k) => {
7378
let cell = row[k] === null || row[k] === undefined ? "" : row[k];
7479

75-
cell =
76-
cell instanceof Date
77-
? cell.toLocaleString()
78-
: cell.toString().replace(/"/g, '""');
80+
cell = ParseService.parseLiteral(
81+
cell as Literal,
82+
InputType.MARKDOWN,
83+
view.diskConfig.yaml.config
84+
) as string;
7985

80-
if (cell.search(/("|,|\n)/g) >= 0) {
86+
if (cell.toString().search(/("|,|\n)/g) >= 0) {
8187
cell = `"${cell}"`;
8288
}
8389
return cell;

0 commit comments

Comments
 (0)