@@ -83,13 +83,7 @@ export async function action({ request }: Route.ActionArgs) {
8383 return { success : false }
8484}
8585
86- function formatLastChecked ( date : string | null ) : string {
87- if ( ! date ) return 'Never'
88- const now = new Date ( )
89- const checked = new Date ( date )
90- const diffMs = now . getTime ( ) - checked . getTime ( )
91- const diffDays = Math . floor ( diffMs / ( 1000 * 60 * 60 * 24 ) )
92-
86+ function formatRelative ( diffDays : number ) : string {
9387 if ( diffDays <= 0 ) return 'Today'
9488 if ( diffDays === 1 ) return 'Yesterday'
9589 if ( diffDays < 7 ) return `${ diffDays } days ago`
@@ -101,6 +95,19 @@ function formatLastChecked(date: string | null): string {
10195 return `${ months } ${ months === 1 ? 'month' : 'months' } ago`
10296}
10397
98+ function formatLastChecked ( date : string | null ) : string {
99+ if ( ! date ) return 'Never'
100+ const checked = new Date ( date )
101+ const diffMs = Date . now ( ) - checked . getTime ( )
102+ const diffDays = Math . floor ( diffMs / ( 1000 * 60 * 60 * 24 ) )
103+ const relative = formatRelative ( diffDays )
104+ const localized = checked . toLocaleString ( undefined , {
105+ dateStyle : 'medium' ,
106+ timeStyle : 'short' ,
107+ } )
108+ return `${ relative } (${ localized } )`
109+ }
110+
104111export default function Sites ( ) {
105112 const { sites } = useLoaderData < typeof loader > ( )
106113 const [ editSite , setEditSite ] = useState < JobPostingSite | null > ( null )
0 commit comments