format last fetched at as date + time

This commit is contained in:
Hongbo Wu 2023-07-20 13:41:12 +08:00
parent 7ceb96a93e
commit 40f681db2e
2 changed files with 10 additions and 2 deletions

View file

@ -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))
}

View file

@ -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'
}`}
</StyledText>