date parser

This commit is contained in:
VividTruthKeeper 2022-12-17 23:36:35 +05:00
parent eba5f3c346
commit 66575f38e7
2 changed files with 6 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import {
} from "chart.js";
import { Api } from "../helpers/api";
import { useState, useEffect } from "react";
import { parseDate } from "../helpers/functions";
ChartJS.register(
LineElement,
@ -37,7 +38,7 @@ const LineChart = ({ activeRow, tabIndex }) => {
const data = {
labels: dataLineChart
? dataLineChart.data[activeRow].all_prices.map((price) =>
price.date.split(" ")[0].replace("-", ".").replace("-", ".")
parseDate(price.date)
)
: [""],

View File

@ -4,3 +4,7 @@
export const dateReverse = (date) => {
return date.split("-").reverse().join(".");
};
export const parseDate = (date) => {
return date.split(" ")[0].split("-").reverse().join(".");
};