diff --git a/app/javascript/mastodon/components/edited_timestamp/index.jsx b/app/javascript/mastodon/components/edited_timestamp/index.jsx index fbf14ec4bde..f8fa0432597 100644 --- a/app/javascript/mastodon/components/edited_timestamp/index.jsx +++ b/app/javascript/mastodon/components/edited_timestamp/index.jsx @@ -6,6 +6,7 @@ import { FormattedMessage, injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import { openModal } from 'mastodon/actions/modal'; +import { FormattedDateWrapper } from 'mastodon/components/formatted_date'; import InlineAccount from 'mastodon/components/inline_account'; import { RelativeTimestamp } from 'mastodon/components/relative_timestamp'; @@ -60,12 +61,12 @@ class EditedTimestamp extends PureComponent { }; render () { - const { timestamp, intl, statusId } = this.props; + const { timestamp, statusId } = this.props; return ( ); diff --git a/app/javascript/mastodon/components/formatted_date.tsx b/app/javascript/mastodon/components/formatted_date.tsx new file mode 100644 index 00000000000..cc927b08737 --- /dev/null +++ b/app/javascript/mastodon/components/formatted_date.tsx @@ -0,0 +1,26 @@ +import type { ComponentProps } from 'react'; + +import { FormattedDate } from 'react-intl'; + +export const FormattedDateWrapper = ( + props: ComponentProps & { className?: string }, +) => ( + + {(date) => ( + + )} + +); + +const tryIsoString = (date?: string | number | Date): string => { + if (!date) { + return ''; + } + try { + return new Date(date).toISOString(); + } catch { + return date.toString(); + } +}; diff --git a/app/javascript/mastodon/features/account_timeline/components/account_header.tsx b/app/javascript/mastodon/features/account_timeline/components/account_header.tsx index 968224bf791..9505d480109 100644 --- a/app/javascript/mastodon/features/account_timeline/components/account_header.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/account_header.tsx @@ -37,6 +37,7 @@ import { FollowingCounter, StatusesCounter, } from 'mastodon/components/counters'; +import { FormattedDateWrapper } from 'mastodon/components/formatted_date'; import { Icon } from 'mastodon/components/icon'; import { IconButton } from 'mastodon/components/icon_button'; import { LoadingIndicator } from 'mastodon/components/loading_indicator'; @@ -938,11 +939,12 @@ export const AccountHeader: React.FC<{ />
- {intl.formatDate(account.created_at, { - year: 'numeric', - month: 'short', - day: '2-digit', - })} +
diff --git a/app/javascript/mastodon/features/privacy_policy/index.tsx b/app/javascript/mastodon/features/privacy_policy/index.tsx index f0309c27123..cd6f9f3b2b0 100644 --- a/app/javascript/mastodon/features/privacy_policy/index.tsx +++ b/app/javascript/mastodon/features/privacy_policy/index.tsx @@ -1,17 +1,13 @@ import { useState, useEffect } from 'react'; -import { - FormattedMessage, - FormattedDate, - useIntl, - defineMessages, -} from 'react-intl'; +import { FormattedMessage, useIntl, defineMessages } from 'react-intl'; import { Helmet } from 'react-helmet'; import { apiGetPrivacyPolicy } from 'mastodon/api/instance'; import type { ApiPrivacyPolicyJSON } from 'mastodon/api_types/instance'; import { Column } from 'mastodon/components/column'; +import { FormattedDateWrapper } from 'mastodon/components/formatted_date'; import { Skeleton } from 'mastodon/components/skeleton'; const messages = defineMessages({ @@ -58,7 +54,7 @@ const PrivacyPolicy: React.FC<{ date: loading ? ( ) : ( - -