Fixing date formatting bug, attempt 3
This commit is contained in:
parent
23ac4c36b4
commit
73e00e2038
1 changed files with 11 additions and 3 deletions
|
@ -23,8 +23,16 @@ const {
|
||||||
|
|
||||||
const locale = 'ru-RU';
|
const locale = 'ru-RU';
|
||||||
|
|
||||||
if (!Intl.DateTimeFormat.supportedLocalesOf(locale)) {
|
function formatDate(obj?: Date) {
|
||||||
Intl.DateTimeFormat = require('intl').DateTimeFormat;
|
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)) {
|
||||||
<h1>{title}</h1>
|
<h1>{title}</h1>
|
||||||
<address>
|
<address>
|
||||||
on
|
on
|
||||||
<time datetime={date?.toISOString()}>{date?.toLocaleDateString(locale)}</time>
|
<time datetime={date?.toISOString()}>{formatDate(date)}</time>
|
||||||
by
|
by
|
||||||
<a href="https://t.me/dcat09" rel="author">DarkCat09</a>
|
<a href="https://t.me/dcat09" rel="author">DarkCat09</a>
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Reference in a new issue