Fixing date formatting, attempt 4, now I've checked that polyfill works on my VPS

This commit is contained in:
DarkCat09 2023-07-31 12:17:33 +04:00
parent 73e00e2038
commit 3f439e0d9a

View file

@ -2,6 +2,7 @@
import ArticleMenu from './ArticleMenu.astro'; import ArticleMenu from './ArticleMenu.astro';
import { AstroComponentFactory } from 'astro/dist/runtime/server'; import { AstroComponentFactory } from 'astro/dist/runtime/server';
import IntlPolyfill from 'intl';
export interface Props { export interface Props {
PostContent: AstroComponentFactory; PostContent: AstroComponentFactory;
@ -29,7 +30,7 @@ function formatDate(obj?: Date) {
const formatter = ( const formatter = (
Intl.DateTimeFormat.supportedLocalesOf(locale).length ? Intl.DateTimeFormat.supportedLocalesOf(locale).length ?
Intl.DateTimeFormat : Intl.DateTimeFormat :
require('intl').DateTimeFormat IntlPolyfill.DateTimeFormat
); );
return new formatter(locale).format(obj); return new formatter(locale).format(obj);