2023-06-06 18:32:48 +03:00
|
|
|
import { HTMLAttributes } from "react";
|
2023-06-05 18:58:59 +03:00
|
|
|
import { UserStats } from "../types";
|
|
|
|
|
2023-06-06 18:32:48 +03:00
|
|
|
interface DateComponentProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
|
date: UserStats["date"];
|
|
|
|
}
|
|
|
|
|
|
|
|
export const DateComponent = ({
|
|
|
|
date,
|
|
|
|
...props
|
|
|
|
}: DateComponentProps): JSX.Element => {
|
2023-06-05 18:58:59 +03:00
|
|
|
// Extract year, month, and day from the date string
|
|
|
|
const year = date.slice(0, 4);
|
|
|
|
const month = date.slice(4, 6);
|
|
|
|
const day = date.slice(6, 8);
|
|
|
|
|
|
|
|
const formattedDate = new Date(
|
|
|
|
`${year}-${month}-${day}`
|
|
|
|
).toLocaleDateString();
|
|
|
|
|
2023-06-06 18:32:48 +03:00
|
|
|
return <span {...props}>{formattedDate}</span>;
|
2023-06-05 18:58:59 +03:00
|
|
|
};
|