Bluesky app fork with some witchin' additions 💫

add dot separated time style (#9455)

authored by samuel.fm and committed by

GitHub 0ba4edab 1eacf427

+13 -3
+11 -1
src/lib/strings/time.ts
··· 1 import {type I18n} from '@lingui/core' 2 3 export function niceDate( 4 i18n: I18n, 5 date: number | string | Date, 6 - dateStyle: 'short' | 'medium' | 'long' | 'full' = 'long', 7 ) { 8 const d = new Date(date) 9 10 return i18n.date(d, { 11 dateStyle,
··· 1 import {type I18n} from '@lingui/core' 2 + import {msg} from '@lingui/macro' 3 4 export function niceDate( 5 i18n: I18n, 6 date: number | string | Date, 7 + dateStyle: 'short' | 'medium' | 'long' | 'full' | 'dot separated' = 'long', 8 ) { 9 const d = new Date(date) 10 + 11 + if (dateStyle === 'dot separated') { 12 + return i18n._( 13 + msg({ 14 + context: 'date and time formatted like this: [time] · [date]', 15 + message: `${i18n.date(d, {timeStyle: 'short'})} · ${i18n.date(d, {day: 'numeric', month: 'numeric', year: '2-digit'})}`, 16 + }), 17 + ) 18 + } 19 20 return i18n.date(d, { 21 dateStyle,
+2 -2
src/screens/PostThread/components/ThreadItemAnchor.tsx
··· 570 <BackdatedPostIndicator post={post} /> 571 <View style={[a.flex_row, a.align_center, a.flex_wrap, a.gap_sm]}> 572 <Text style={[a.text_sm, t.atoms.text_contrast_medium]}> 573 - {niceDate(i18n, post.indexedAt, 'medium')} 574 </Text> 575 {isRootPost && ( 576 <WhoCanReply post={post} isThreadAuthor={isThreadAuthor} /> ··· 655 a.leading_tight, 656 t.atoms.text_contrast_medium, 657 ]}> 658 - <Trans>Archived from {niceDate(i18n, createdAt)}</Trans> 659 </Text> 660 </View> 661 )}
··· 570 <BackdatedPostIndicator post={post} /> 571 <View style={[a.flex_row, a.align_center, a.flex_wrap, a.gap_sm]}> 572 <Text style={[a.text_sm, t.atoms.text_contrast_medium]}> 573 + {niceDate(i18n, post.indexedAt, 'dot separated')} 574 </Text> 575 {isRootPost && ( 576 <WhoCanReply post={post} isThreadAuthor={isThreadAuthor} /> ··· 655 a.leading_tight, 656 t.atoms.text_contrast_medium, 657 ]}> 658 + <Trans>Archived from {niceDate(i18n, createdAt, 'medium')}</Trans> 659 </Text> 660 </View> 661 )}