Skip to content

Commit

Permalink
fix: stats page date format (#2093)
Browse files Browse the repository at this point in the history
* fix fleek base url

* undo url

* improve UTC timestamps
  • Loading branch information
Tburm authored Mar 9, 2023
1 parent bab5455 commit 0a7b309
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

1 comment on commit 0a7b309

@vercel
Copy link

@vercel vercel bot commented on 0a7b309 Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kwenta-storybook – ./

kwenta-storybook-git-perps-v2-dev-kwenta.vercel.app
kwenta-storybook-kwenta.vercel.app

Please sign in to comment.