From 40f681db2e45a260e3b0908eb6a1d204c544161c Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 20 Jul 2023 13:41:12 +0800 Subject: [PATCH] format last fetched at as date + time --- packages/web/lib/dateFormatting.ts | 8 ++++++++ packages/web/pages/settings/rss/index.tsx | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/web/lib/dateFormatting.ts b/packages/web/lib/dateFormatting.ts index e31384041..2ae152bad 100644 --- a/packages/web/lib/dateFormatting.ts +++ b/packages/web/lib/dateFormatting.ts @@ -24,3 +24,11 @@ export function formattedShortTime(rawDate: string): string { timeZone, }).format(new Date(rawDate)) } + +export function formattedDateTime(rawDate: string): string { + return new Intl.DateTimeFormat(locale, { + dateStyle: 'short', + timeStyle: 'short', + timeZone, + }).format(new Date(rawDate)) +} diff --git a/packages/web/pages/settings/rss/index.tsx b/packages/web/pages/settings/rss/index.tsx index 79c02c01e..332e7f8ab 100644 --- a/packages/web/pages/settings/rss/index.tsx +++ b/packages/web/pages/settings/rss/index.tsx @@ -11,7 +11,7 @@ import { SettingsTableRow, } from '../../../components/templates/settings/SettingsTable' import { theme } from '../../../components/tokens/stitches.config' -import { formattedShortTime } from '../../../lib/dateFormatting' +import { formattedDateTime } from '../../../lib/dateFormatting' import { unsubscribeMutation } from '../../../lib/networking/mutations/unsubscribeMutation' import { updateSubscriptionMutation } from '../../../lib/networking/mutations/updateSubscriptionMutation' import { @@ -155,7 +155,7 @@ export default function Rss(): JSX.Element { {`URL: ${subscription.url}, `} {`Last fetched: ${ subscription.lastFetchedAt - ? formattedShortTime(subscription.lastFetchedAt) + ? formattedDateTime(subscription.lastFetchedAt) : 'Never' }`}