feat(mobile): Avatar + ConversationRow + relative-time helper
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// Minimal relative-time formatter for chat lists. Matches the desktop's
|
||||
// terse style ("Vor 5 Min", "Gestern", "12.05.").
|
||||
export function formatRelativeTime(iso: string | null): string {
|
||||
if (!iso) return '';
|
||||
const then = new Date(iso).getTime();
|
||||
if (!Number.isFinite(then)) return '';
|
||||
const diffSec = (Date.now() - then) / 1000;
|
||||
if (diffSec < 60) return 'Gerade eben';
|
||||
if (diffSec < 3600) return 'Vor ' + Math.floor(diffSec / 60) + ' Min';
|
||||
if (diffSec < 86400) return 'Vor ' + Math.floor(diffSec / 3600) + ' Std';
|
||||
if (diffSec < 86400 * 2) return 'Gestern';
|
||||
const d = new Date(iso);
|
||||
return [
|
||||
String(d.getDate()).padStart(2, '0'),
|
||||
String(d.getMonth() + 1).padStart(2, '0'),
|
||||
String(d.getFullYear()).slice(-2),
|
||||
].join('.');
|
||||
}
|
||||
Reference in New Issue
Block a user