|
|
@ -15,22 +15,21 @@ const textSizes = {
|
|
|
|
export default function DateTime({ options }) {
|
|
|
|
export default function DateTime({ options }) {
|
|
|
|
const { text_size: textSize, format } = options;
|
|
|
|
const { text_size: textSize, format } = options;
|
|
|
|
const { i18n } = useTranslation();
|
|
|
|
const { i18n } = useTranslation();
|
|
|
|
const [date, setDate] = useState(new Date());
|
|
|
|
const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
|
|
|
|
|
|
|
|
const [date, setDate] = useState("");
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
setDate(new Date());
|
|
|
|
setDate(dateFormat.format(new Date()));
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
}, [setDate]);
|
|
|
|
}, [date, setDate]);
|
|
|
|
|
|
|
|
|
|
|
|
const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="flex flex-col justify-center first:ml-0 ml-4">
|
|
|
|
<div className="flex flex-col justify-center first:ml-0 ml-4">
|
|
|
|
<div className="flex flex-row items-center grow justify-end">
|
|
|
|
<div className="flex flex-row items-center grow justify-end">
|
|
|
|
<span className={`text-theme-800 dark:text-theme-200 ${textSizes[textSize || "lg"]}`}>
|
|
|
|
<span className={`text-theme-800 dark:text-theme-200 ${textSizes[textSize || "lg"]}`}>
|
|
|
|
{dateFormat.format(date)}
|
|
|
|
{date}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|