Skip to content

Commit 3c565e5

Browse files
chore: Tweak date formatting
1 parent 5726421 commit 3c565e5

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

src/components/BlocksChart.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import React from 'react';
1313
import _ from 'lodash';
14-
import { format, parseISO } from 'date-fns';
14+
import { intlFormat } from 'date-fns';
1515
import {
1616
CartesianGrid,
1717
Legend,
@@ -109,20 +109,29 @@ const BlocksChart = (props: BlocksChartProps) => {
109109
});
110110

111111
const timestampFormat = (timestamp: number): string => {
112-
return format(
113-
parseISO(new Date(timestamp * 1000).toISOString().slice(0, -1)),
114-
'M/d/yyyy, hh:mm aa'
115-
);
112+
return intlFormat(new Date(timestamp * 1000), {
113+
year: 'numeric',
114+
month: 'numeric',
115+
day: 'numeric',
116+
hour: 'numeric',
117+
minute: 'numeric',
118+
timeZone: 'UTC',
119+
});
116120
};
117121

118122
const tooltipFormatter = (value, name) => {
119123
if (name === 'Difficulty') {
120124
return value;
121125
} else if (name === 'Time') {
122-
return format(
123-
parseISO(new Date(value * 1000).toISOString().slice(0, -1)),
124-
"MMMM d, yyyy 'at' hh:mm aa 'UTC'"
125-
);
126+
return intlFormat(new Date(value * 1000), {
127+
day: 'numeric',
128+
month: 'long',
129+
year: 'numeric',
130+
hour: 'numeric',
131+
minute: '2-digit',
132+
timeZone: 'UTC',
133+
timeZoneName: 'short',
134+
});
126135
}
127136
return value;
128137
};

0 commit comments

Comments
 (0)