mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-12 15:46:34 +02:00
feat: add proxy check button
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Get flag icon CSS class for a country code (ISO 3166-1 alpha-2)
|
||||
*/
|
||||
export function getFlagIconClass(countryCode: string): string {
|
||||
if (!countryCode || countryCode.length !== 2) {
|
||||
return "";
|
||||
}
|
||||
return `fi fi-${countryCode.toLowerCase()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format relative time (e.g., "2 minutes ago", "1 hour ago")
|
||||
*/
|
||||
export function formatRelativeTime(timestamp: number): string {
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
const secondsAgo = now - timestamp;
|
||||
|
||||
if (secondsAgo < 60) {
|
||||
return "just now";
|
||||
}
|
||||
|
||||
const minutesAgo = Math.floor(secondsAgo / 60);
|
||||
if (minutesAgo < 60) {
|
||||
return `${minutesAgo} minute${minutesAgo !== 1 ? "s" : ""} ago`;
|
||||
}
|
||||
|
||||
const hoursAgo = Math.floor(minutesAgo / 60);
|
||||
if (hoursAgo < 24) {
|
||||
return `${hoursAgo} hour${hoursAgo !== 1 ? "s" : ""} ago`;
|
||||
}
|
||||
|
||||
const daysAgo = Math.floor(hoursAgo / 24);
|
||||
return `${daysAgo} day${daysAgo !== 1 ? "s" : ""} ago`;
|
||||
}
|
||||
Reference in New Issue
Block a user