diff --git a/frontend/src/app/uptime/page.tsx b/frontend/src/app/uptime/page.tsx index 910b66b..1b65574 100644 --- a/frontend/src/app/uptime/page.tsx +++ b/frontend/src/app/uptime/page.tsx @@ -12,95 +12,74 @@ export default async function Home() { // Calculate timestamp for 24 hours ago const twentyFourHoursAgo = Date.now() - (24 * 60 * 60 * 1000); + // Format time consistently using users's timezone + const formatTimeToLocal = (timestamp: number) => { + return new Date(timestamp).toLocaleTimeString(undefined, { + hour: 'numeric', + minute: '2-digit', + hour12: true + }).toLowerCase(); + }; + + // Format date with time for tooltips + const formatDateTimeToLocal = (timestamp: number) => { + return new Date(timestamp).toLocaleString(undefined, { + month: 'short', + day: 'numeric', + hour: 'numeric', + minute: '2-digit' + }); + }; + return (

Uptime Monitor

-
+
{services.map((service: Service, index: any) => { - // Filter services to only show last 24 hours const last24HourServices = service.last10services.filter(s => Number(s.status.labels.timestamp) > twentyFourHoursAgo ); return (
-
{service.name}
+
{service.name}
-
- {last24HourServices.map((lastService, index) => { - const dateTime = new Intl.DateTimeFormat('en-US', { - year: 'numeric', - month: 'numeric', - day: 'numeric', - hour: 'numeric', - minute: 'numeric', - second: 'numeric' - }).format(Number(lastService.status.labels.timestamp)) - - return ( -
{ - alert( - `Status: ${lastService.status.value === 1 ? 'Up' : 'Down'}\n` + - `Time: ${new Intl.DateTimeFormat('en-US', { - month: 'short', - day: 'numeric', - hour: 'numeric', - minute: '2-digit' - }).format(Number(lastService.status.labels.timestamp))}\n` + - `${lastService.status.value === 0 ? 'Error: Service was unreachable' : 'Service was operating normally'}` - ) - }}> - {new Intl.DateTimeFormat('en-US', { - month: 'short', - day: 'numeric', - hour: 'numeric', - minute: '2-digit' - }).format(Number(lastService.status.labels.timestamp))} -   -
- ) - })} +
+ {last24HourServices.map((lastService, index) => { + const timestamp = Number(lastService.status.labels.timestamp); + + return ( +
{ + alert( + `Status: ${lastService.status.value === 1 ? 'Up' : 'Down'}\n` + + `Time: ${formatDateTimeToLocal(timestamp)}\n` + + `${lastService.status.value === 0 ? 'Error: Service was unreachable' : 'Service was operating normally'}` + ) + }}> + + {formatDateTimeToLocal(timestamp)} + +   +
+ ) + })} +
-
-
-
-
-
+
{formatDistanceToNow(new Date(Number(last24HourServices[0]?.status.labels.timestamp)))} ago
-
-
+
+
{(last24HourServices.filter(s => s.status.value === 1).length / last24HourServices.length * 100).toFixed(2)} @@ -108,8 +87,10 @@ export default async function Home() { % uptime
-
-
{new Date().toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }).toLowerCase()}
+
+
+ {formatTimeToLocal(Date.now())} +
)})}