diff --git a/striker-ui/lib/extended_date/ExtendedDate.ts b/striker-ui/lib/extended_date/ExtendedDate.ts new file mode 100644 index 00000000..d6ad5495 --- /dev/null +++ b/striker-ui/lib/extended_date/ExtendedDate.ts @@ -0,0 +1,18 @@ +class ExtendedDate extends Date { + toLocaleISOString(): string { + const localeDateParts: string[] = this.toLocaleDateString('en-US', { + year: 'numeric', + month: '2-digit', + day: '2-digit', + }).split('/', 3); + const localDate = `${localeDateParts[2]}-${localeDateParts[0]}-${localeDateParts[1]}`; + const localeTime: string = this.toLocaleTimeString('en-US', { + hour12: false, + }); + const timezoneOffset: number = (this.getTimezoneOffset() / 60) * -1; + + return `${localDate}T${localeTime}${timezoneOffset}`; + } +} + +export default ExtendedDate; diff --git a/striker-ui/pages/anvils/[uuid].tsx b/striker-ui/pages/anvils/[uuid].tsx index 7118cd09..d88cfb8b 100644 --- a/striker-ui/pages/anvils/[uuid].tsx +++ b/striker-ui/pages/anvils/[uuid].tsx @@ -4,14 +4,15 @@ import { useRouter } from 'next/dist/client/router'; import DEFAULT_THEME from '../../lib/consts/DEFAULT_THEME'; +import ExtendedDate from '../../lib/extended_date/ExtendedDate'; import Header from '../../components/organisms/Header'; +import Label from '../../components/atoms/Label'; import List from '../../components/molecules/List'; import PageCenterContainer from '../../components/organisms/PageCenterContainer'; import PageContainer from '../../components/organisms/PageContainer'; import ToggleSwitch from '../../components/atoms/ToggleSwitch'; import useOneAnvil from '../../lib/anvil/useOneAnvil'; -import Label from '../../components/atoms/Label'; const StyledAnvilNodeStatus = styled.div` display: flex; @@ -52,7 +53,9 @@ const DemoAnvilStatus: NextPage = (): JSX.Element => { isLoading, } = useOneAnvil(anvilUUID); - const lastUpdatedDatetime: string = new Date(timestamp * 1000).toISOString(); + const lastUpdatedDatetime: string = new ExtendedDate( + timestamp * 1000, + ).toLocaleISOString(); return (