From 84b7f103c38e362a78485807f439f7d3bb32cd09 Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 4 Jan 2023 13:53:06 -0800 Subject: [PATCH] Allow setting locale for datetime widget directly --- src/components/widgets/datetime/datetime.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/widgets/datetime/datetime.jsx b/src/components/widgets/datetime/datetime.jsx index 7953e7739..869834736 100644 --- a/src/components/widgets/datetime/datetime.jsx +++ b/src/components/widgets/datetime/datetime.jsx @@ -13,17 +13,18 @@ const textSizes = { }; export default function DateTime({ options }) { - const { text_size: textSize, format } = options; + const { text_size: textSize, locale, format } = options; const { i18n } = useTranslation(); const [date, setDate] = useState(""); + const dateLocale = locale ?? i18n.language; useEffect(() => { - const dateFormat = new Intl.DateTimeFormat(i18n.language, { ...format }); + const dateFormat = new Intl.DateTimeFormat(dateLocale, { ...format }); const interval = setInterval(() => { setDate(dateFormat.format(new Date())); }, 1000); return () => clearInterval(interval); - }, [date, setDate, i18n.language, format]); + }, [date, setDate, dateLocale, format]); return (