moment#unix TypeScript Examples

The following examples show how to use moment#unix. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useProposal.ts    From dxvote with GNU Affero General Public License v3.0 6 votes vote down vote up
formatterMiddleware: Middleware =
  (useSWRNext: SWRHook) => (key, fetcher, config) => {
    const swr = useSWRNext(key, fetcher, config);
    if (swr.data) {
      const original = swr.data as any;

      const clone: any = Object.assign({}, swr.data);
      clone.startTime = original.startTime
        ? unix(original.startTime.toNumber())
        : null;
      clone.endTime = original.endTime
        ? unix(original.endTime.toNumber())
        : null;

      return { ...swr, data: clone };
    }
    return swr;
  }
Example #2
Source File: useVoterLockTimestamp.ts    From dxvote with GNU Affero General Public License v3.0 6 votes vote down vote up
useVoterLockTimestamp = (
  contractAddress: string,
  userAddress: string
) => {
  const { data, ...rest } = useEtherSWR<BigNumber>(
    contractAddress && userAddress
      ? [contractAddress, 'getVoterLockTimestamp', userAddress]
      : [],
    {
      ABIs: new Map([[contractAddress, ERC20GuildContract.abi]]),
    }
  );

  // TODO: Move this into a SWR middleware
  const parsed = useMemo(() => {
    if (!data) return undefined;

    return unix(data.toNumber());
  }, [data]);

  return { data: parsed, ...rest };
}