- Integrated CreditOverview and RecentTransactions components into the dashboard for better credit visibility. - Updated canvas toolbar to display current credit balance using CreditDisplay. - Improved AI image and prompt nodes to show credit costs and handle credit availability checks during image generation. - Added new queries for fetching recent transactions and monthly usage statistics to support dashboard features. - Refactored existing code to streamline credit-related functionalities across components.
21 lines
657 B
TypeScript
21 lines
657 B
TypeScript
/**
|
|
* Formatiert einen Timestamp als relative Zeitangabe.
|
|
* Beispiele: "Just now", "5m ago", "3h ago", "2d ago", "12. Mär"
|
|
*/
|
|
export function formatRelativeTime(timestamp: number): string {
|
|
const now = Date.now();
|
|
const diff = now - timestamp;
|
|
const minutes = Math.floor(diff / 60000);
|
|
const hours = Math.floor(diff / 3600000);
|
|
const days = Math.floor(diff / 86400000);
|
|
|
|
if (minutes < 1) return "Just now";
|
|
if (minutes < 60) return `${minutes}m ago`;
|
|
if (hours < 24) return `${hours}h ago`;
|
|
if (days < 7) return `${days}d ago`;
|
|
return new Date(timestamp).toLocaleDateString("de-DE", {
|
|
day: "numeric",
|
|
month: "short",
|
|
});
|
|
}
|