-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-date.html
More file actions
33 lines (30 loc) · 833 Bytes
/
fix-date.html
File metadata and controls
33 lines (30 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<html>
<body>
<textarea id="input"></textarea><br/><button onclick="fix()">Date format fix</button><br/><textarea id="output"></textarea>
<script>
window.fix = function fix() {
try {
const txt = document.getElementById("input");
const txt2 = document.getElementById("output");
const str = /data="(.+)"/.exec(txt.value);
const d = JSON.parse(JSON.parse(`"${str[1]}"`));
d.forEach(dd =>
dd.query.layers.forEach(l =>
l.columnSettings.forEach(s => {
if (s.name.includes("date") || s.name.includes("Date")) {
s.format = "MM/dd/yyyy";
}
})
)
);
txt2.value = txt.value.replace(
/data="(.+)"/,
`data=${JSON.stringify(JSON.stringify(d))}`
);
} catch (e) {
console.error(e);
}
};
</script>
</body>
</html>