Files
Aiq-Lite-UI/src/utils/utils.ts
Toba Ojo 97818ca8d9 - Add SystemOverview component and related hooks;
- update Dashboard layout and introduce new UI components
2026-01-07 16:18:14 +00:00

29 lines
877 B
TypeScript

export const formatNumberPlate = (plate: string) => {
const splittedPlate = plate?.split("");
splittedPlate?.splice(4, 0, " ");
const formattedPlate = splittedPlate?.join("");
return formattedPlate;
};
export const timeAgo = (timestampmili: number | null) => {
if (timestampmili === null) return "unknown";
const diffMs = Date.now() - new Date(timestampmili).getTime();
const diffMins = Math.floor(diffMs / 60000);
if (diffMins < 60) {
if (diffMins < 1) {
return "Just now";
}
return `${diffMins === 1 ? "1 minute" : diffMins + " minutes"} ago`;
} else {
const diffHours = Math.floor(diffMins / 60);
if (diffHours < 1) {
return "just now";
}
return `${diffHours === 1 ? "1 hour" : diffHours + " hours"} ago`;
}
};
export function capitalize(s?: string) {
return s ? s.charAt(0).toUpperCase() + s.slice(1) : "";
}