diff --git a/src/components/Article.astro b/src/components/Article.astro index afa1da3..bffa206 100644 --- a/src/components/Article.astro +++ b/src/components/Article.astro @@ -23,8 +23,16 @@ const { const locale = 'ru-RU'; -if (!Intl.DateTimeFormat.supportedLocalesOf(locale)) { - Intl.DateTimeFormat = require('intl').DateTimeFormat; +function formatDate(obj?: Date) { + if (!obj) return null; + + const formatter = ( + Intl.DateTimeFormat.supportedLocalesOf(locale).length ? + Intl.DateTimeFormat : + require('intl').DateTimeFormat + ); + + return new formatter(locale).format(obj); } --- @@ -32,7 +40,7 @@ if (!Intl.DateTimeFormat.supportedLocalesOf(locale)) {