fix(striker-ui): extend Date to output iso-8601 with timezone

main
Tsu-ba-me 4 years ago
parent f151065ad9
commit 5d4a854eb0
  1. 18
      striker-ui/lib/extended_date/ExtendedDate.ts
  2. 7
      striker-ui/pages/anvils/[uuid].tsx

@ -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;

@ -4,14 +4,15 @@ import { useRouter } from 'next/dist/client/router';
import DEFAULT_THEME from '../../lib/consts/DEFAULT_THEME'; import DEFAULT_THEME from '../../lib/consts/DEFAULT_THEME';
import ExtendedDate from '../../lib/extended_date/ExtendedDate';
import Header from '../../components/organisms/Header'; import Header from '../../components/organisms/Header';
import Label from '../../components/atoms/Label';
import List from '../../components/molecules/List'; import List from '../../components/molecules/List';
import PageCenterContainer from '../../components/organisms/PageCenterContainer'; import PageCenterContainer from '../../components/organisms/PageCenterContainer';
import PageContainer from '../../components/organisms/PageContainer'; import PageContainer from '../../components/organisms/PageContainer';
import ToggleSwitch from '../../components/atoms/ToggleSwitch'; import ToggleSwitch from '../../components/atoms/ToggleSwitch';
import useOneAnvil from '../../lib/anvil/useOneAnvil'; import useOneAnvil from '../../lib/anvil/useOneAnvil';
import Label from '../../components/atoms/Label';
const StyledAnvilNodeStatus = styled.div` const StyledAnvilNodeStatus = styled.div`
display: flex; display: flex;
@ -52,7 +53,9 @@ const DemoAnvilStatus: NextPage = (): JSX.Element => {
isLoading, isLoading,
} = useOneAnvil(anvilUUID); } = useOneAnvil(anvilUUID);
const lastUpdatedDatetime: string = new Date(timestamp * 1000).toISOString(); const lastUpdatedDatetime: string = new ExtendedDate(
timestamp * 1000,
).toLocaleISOString();
return ( return (
<PageContainer> <PageContainer>

Loading…
Cancel
Save