From 0ba4edab8d6cde543109b75fc6fb84a6ea879940 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 1 Dec 2025 17:52:19 +0200 Subject: [PATCH] add dot separated time style (#9455) --- src/lib/strings/time.ts | 12 +++++++++++- .../PostThread/components/ThreadItemAnchor.tsx | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts index a44bfdbe4d..215ac369ea 100644 --- a/src/lib/strings/time.ts +++ b/src/lib/strings/time.ts @@ -1,12 +1,22 @@ import {type I18n} from '@lingui/core' +import {msg} from '@lingui/macro' export function niceDate( i18n: I18n, date: number | string | Date, - dateStyle: 'short' | 'medium' | 'long' | 'full' = 'long', + dateStyle: 'short' | 'medium' | 'long' | 'full' | 'dot separated' = 'long', ) { const d = new Date(date) + if (dateStyle === 'dot separated') { + return i18n._( + msg({ + context: 'date and time formatted like this: [time] · [date]', + message: `${i18n.date(d, {timeStyle: 'short'})} · ${i18n.date(d, {day: 'numeric', month: 'numeric', year: '2-digit'})}`, + }), + ) + } + return i18n.date(d, { dateStyle, timeStyle: 'short', diff --git a/src/screens/PostThread/components/ThreadItemAnchor.tsx b/src/screens/PostThread/components/ThreadItemAnchor.tsx index 829084808e..7785afe2ca 100644 --- a/src/screens/PostThread/components/ThreadItemAnchor.tsx +++ b/src/screens/PostThread/components/ThreadItemAnchor.tsx @@ -570,7 +570,7 @@ function ExpandedPostDetails({ - {niceDate(i18n, post.indexedAt, 'medium')} + {niceDate(i18n, post.indexedAt, 'dot separated')} {isRootPost && ( @@ -655,7 +655,7 @@ function BackdatedPostIndicator({post}: {post: AppBskyFeedDefs.PostView}) { a.leading_tight, t.atoms.text_contrast_medium, ]}> - Archived from {niceDate(i18n, createdAt)} + Archived from {niceDate(i18n, createdAt, 'medium')} )}