Skip to content

Commit

Permalink
fix: stats page date format (#2093)
Browse files Browse the repository at this point in the history
fix: stats page date format (#2093)
  • Loading branch information
platschi authored Mar 9, 2023
2 parents 16aaf7e + 0a7b309 commit b503761
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sections/stats/charts/Traders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTheme } from 'styled-components';

import { MiniLoader } from 'components/Loader';
import useStatsData from 'hooks/useStatsData';
import { formatShortDate, toJSTimestamp } from 'utils/formatters/date';
import { formatShortDateUTC, toJSTimestamp } from 'utils/formatters/date';

import { initChart } from '../initChart';
import type { EChartsOption } from '../initChart';
Expand Down Expand Up @@ -37,7 +37,7 @@ export const Traders = () => {
xAxis: {
...defaultOptions.xAxis,
type: 'category',
data: dailyStatsData.map(({ timestamp }) => formatShortDate(toJSTimestamp(timestamp))),
data: dailyStatsData.map(({ timestamp }) => formatShortDateUTC(toJSTimestamp(timestamp))),
},
yAxis: [
{
Expand Down
4 changes: 2 additions & 2 deletions sections/stats/charts/Trades.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTheme } from 'styled-components';

import { MiniLoader } from 'components/Loader';
import useStatsData from 'hooks/useStatsData';
import { formatShortDate, toJSTimestamp } from 'utils/formatters/date';
import { formatShortDateUTC, toJSTimestamp } from 'utils/formatters/date';

import { initChart } from '../initChart';
import type { EChartsOption } from '../initChart';
Expand Down Expand Up @@ -37,7 +37,7 @@ export const Trades = () => {
xAxis: {
...defaultOptions.xAxis,
type: 'category',
data: dailyStatsData.map(({ timestamp }) => formatShortDate(toJSTimestamp(timestamp))),
data: dailyStatsData.map(({ timestamp }) => formatShortDateUTC(toJSTimestamp(timestamp))),
},
yAxis: [
{
Expand Down
4 changes: 2 additions & 2 deletions sections/stats/charts/Volume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTheme } from 'styled-components';

import { MiniLoader } from 'components/Loader';
import useStatsData from 'hooks/useStatsData';
import { formatShortDate, toJSTimestamp } from 'utils/formatters/date';
import { formatShortDateUTC, toJSTimestamp } from 'utils/formatters/date';
import { formatDollars } from 'utils/formatters/number';

import { initChart } from '../initChart';
Expand Down Expand Up @@ -44,7 +44,7 @@ export const Volume = () => {
xAxis: {
...defaultOptions.xAxis,
type: 'category',
data: dailyStatsData.map(({ timestamp }) => formatShortDate(toJSTimestamp(timestamp))),
data: dailyStatsData.map(({ timestamp }) => formatShortDateUTC(toJSTimestamp(timestamp))),
},
yAxis: [
{
Expand Down
5 changes: 5 additions & 0 deletions utils/formatters/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const toJSTimestamp = (timestamp: number) => timestamp * 1000;

export const formatShortDate = (date: Date | number) => formatDate(date, 'yyyy-MM-dd');

export const formatShortDateUTC = (date: Date | number) => {
const dateString = new Date(date).toISOString();
return dateString.substring(0, 10);
};

export const formatShortDateWithTime = (date: Date | number) =>
formatDate(date, 'MMM d, yyyy H:mma');
export const formatDateWithTime = (date: Date | number) => formatDate(date, 'd MMM yyyy H:mm');
Expand Down

0 comments on commit b503761

Please sign in to comment.