@parkassist/pa-ui-library
Version:
INX Platform elements
26 lines • 744 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useInterval } from "react-use";
import { useState } from "react";
import dayjs from "dayjs";
var utc = require("dayjs/plugin/utc");
var timezone = require("dayjs/plugin/timezone");
dayjs.extend(utc);
dayjs.extend(timezone);
require("dayjs/locale/es");
require("dayjs/locale/en");
require("dayjs/locale/pl");
require("dayjs/locale/fr");
require("dayjs/locale/he");
export function CustomClock({
timezone,
format,
language,
languages
}) {
const [timeStamp, setTimeStamp] = useState(Date.now() / 1000);
dayjs.locale(language);
useInterval(() => setTimeStamp(Date.now() / 1000), 100);
return _jsx("div", {
children: dayjs().tz(timezone).format(format)
}, timeStamp);
}