Format date with Tz
This commit is contained in:
1 parent
d8664d3ed7
commit
10dd595cbc
2 files changed
+8
-8
No files matched your search
@@ -11,9 +11,9 @@ import {
|
|||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import "./index.css";
|
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../Utils/timeUtils";
|
||||||
|
import "./index.css";
|
||||||
|
|
||||||
const CustomToolTip = ({ active, payload, label }) => {
|
const CustomToolTip = ({ active, payload, label }) => {
|
||||||
const uiTimezone = useSelector((state) => state.ui.timezone);
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import {
|
|||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { Box, Stack, Typography } from "@mui/material";
|
import { Box, Stack, Typography } from "@mui/material";
|
||||||
import { formatDate } from "../../../../Utils/timeUtils";
|
import { formatDateWithTz } from "../../../../Utils/timeUtils";
|
||||||
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
seo: {
|
seo: {
|
||||||
@@ -47,6 +48,8 @@ const config = {
|
|||||||
|
|
||||||
const CustomToolTip = ({ active, payload, label, config }) => {
|
const CustomToolTip = ({ active, payload, label, config }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|
||||||
if (active && payload && payload.length) {
|
if (active && payload && payload.length) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -66,7 +69,7 @@ const CustomToolTip = ({ active, payload, label, config }) => {
|
|||||||
fontWeight: 500,
|
fontWeight: 500,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{formatDate(new Date(label))}
|
{formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
|
||||||
</Typography>
|
</Typography>
|
||||||
{Object.keys(config)
|
{Object.keys(config)
|
||||||
.reverse()
|
.reverse()
|
||||||
@@ -175,6 +178,7 @@ const processDataWithGaps = (data, interval) => {
|
|||||||
*/
|
*/
|
||||||
const CustomTick = ({ x, y, payload, index }) => {
|
const CustomTick = ({ x, y, payload, index }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const uiTimezone = useSelector((state) => state.ui.timezone);
|
||||||
|
|
||||||
// Render nothing for the first tick
|
// Render nothing for the first tick
|
||||||
if (index === 0) return null;
|
if (index === 0) return null;
|
||||||
@@ -188,11 +192,7 @@ const CustomTick = ({ x, y, payload, index }) => {
|
|||||||
fontSize={11}
|
fontSize={11}
|
||||||
fontWeight={400}
|
fontWeight={400}
|
||||||
>
|
>
|
||||||
{formatDate(new Date(payload.value), {
|
{formatDateWithTz(payload?.value, "h:mm a", uiTimezone)}
|
||||||
year: undefined,
|
|
||||||
month: undefined,
|
|
||||||
day: undefined,
|
|
||||||
})}
|
|
||||||
</Text>
|
</Text>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user