Skip to content

Commit d657be1

Browse files
authored
fix: Display ISO string for date objects in views (#2897)
1 parent d74b4f8 commit d657be1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/dashboard/Data/Views/Views.react.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ class Views extends TableView {
128128
.then(results => {
129129
const columns = {};
130130
const computeWidth = str => {
131-
const text = typeof str === 'object' && str !== null ? JSON.stringify(str) : String(str);
131+
let text = str;
132+
if (text === undefined) {
133+
text = '';
134+
} else if (text && typeof text === 'object') {
135+
text = text.__type === 'Date' && text.iso ? text.iso : JSON.stringify(text);
136+
}
137+
text = String(text);
132138
if (typeof document !== 'undefined') {
133139
const canvas =
134140
computeWidth._canvas || (computeWidth._canvas = document.createElement('canvas'));
@@ -298,6 +304,10 @@ class Views extends TableView {
298304
);
299305
} else if (type === 'Object') {
300306
content = JSON.stringify(value);
307+
} else if (type === 'Date') {
308+
content = value && value.iso ? value.iso : String(value);
309+
} else if (value === undefined) {
310+
content = '';
301311
} else {
302312
content = String(value);
303313
}

0 commit comments

Comments
 (0)