From 50fd06057fb5e59b06f4187188a63729f680025a Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 1 Mar 2023 20:07:22 +0800 Subject: [PATCH] Refactor niceDateTime out --- src/components/account.jsx | 9 ++++----- src/components/drafts.jsx | 15 ++------------- src/components/status.jsx | 38 ++++--------------------------------- src/pages/notifications.jsx | 13 ++++--------- src/utils/nice-date-time.js | 19 +++++++++++++++++++ 5 files changed, 33 insertions(+), 61 deletions(-) create mode 100644 src/utils/nice-date-time.js diff --git a/src/components/account.jsx b/src/components/account.jsx index 73ed46be..76dc18c7 100644 --- a/src/components/account.jsx +++ b/src/components/account.jsx @@ -7,6 +7,7 @@ import { api } from '../utils/api'; import emojifyText from '../utils/emojify-text'; import enhanceContent from '../utils/enhance-content'; import handleContentLinks from '../utils/handle-content-links'; +import niceDateTime from '../utils/nice-date-time'; import shortenNumber from '../utils/shorten-number'; import states, { hideAllModals } from '../utils/states'; import store from '../utils/store'; @@ -205,11 +206,9 @@ function Account({ account, instance: propInstance, onClose }) {
diff --git a/src/components/drafts.jsx b/src/components/drafts.jsx index 28c7c35d..61f694af 100644 --- a/src/components/drafts.jsx +++ b/src/components/drafts.jsx @@ -4,6 +4,7 @@ import { useEffect, useMemo, useReducer, useState } from 'react'; import { api } from '../utils/api'; import db from '../utils/db'; +import niceDateTime from '../utils/nice-date-time'; import states from '../utils/states'; import { getCurrentAccountNS } from '../utils/store-utils'; @@ -81,19 +82,7 @@ function Drafts() {
)} - {Intl.DateTimeFormat('en', { - // Show year if not current year - year: - updatedAtDate.getFullYear() === currentYear - ? undefined - : 'numeric', - month: 'short', - day: 'numeric', - weekday: 'short', - hour: 'numeric', - minute: '2-digit', - second: '2-digit', - }).format(updatedAtDate)} + {niceDateTime(updatedAtDate)}