Skip to content

Commit 180fcb0

Browse files
committed
change formatDate function
1 parent afa2963 commit 180fcb0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

devtools/frontend/src/components/LogWindow.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import { forwardRef } from "react";
22
import * as css from "./LogWindow.css";
33

4-
const formatDate = (date: Date) => {
5-
return Intl.DateTimeFormat(undefined, {
6-
timeStyle: "medium",
7-
}).format(date);
8-
};
4+
function formatDate(date: Date) {
5+
let p = new Intl.DateTimeFormat("en", {
6+
year: "numeric",
7+
month: "2-digit",
8+
day: "2-digit",
9+
hour: "2-digit",
10+
minute: "2-digit",
11+
})
12+
.formatToParts(date)
13+
.reduce((acc: any, part) => {
14+
acc[part.type] = part.value;
15+
return acc;
16+
}, {});
17+
18+
return `${p.year}.${p.month}.${p.day} ${p.hour}:${p.minute} ${p.}`;
19+
}
920

1021
const LogWindow = forwardRef<HTMLDivElement>((props, ref) => {
1122
const logs = [

0 commit comments

Comments
 (0)