Update package-lock.json and enhance UptimeStatusIsland component for time formatting

- Updated package-lock.json to reflect new versions of dependencies, including luxon for date handling.
- Modified UptimeStatusIsland component to improve local time formatting, ensuring UTC display and handling of invalid dates.
This commit is contained in:
2025-06-11 20:44:32 +02:00
parent cdc09fc4a5
commit c067466894
3 changed files with 2767 additions and 2453 deletions

View File

@@ -3,6 +3,7 @@ export const prerender = true;
import Layout from '~/layouts/PageLayout.astro';
import StructuredData from '~/components/common/StructuredData.astro';
import Hero from '~/components/widgets/Hero.astro';
import { DateTime } from 'luxon';
import { getTranslation, supportedLanguages } from '~/i18n/translations';
@@ -37,6 +38,24 @@ const tocItems = [
{ id: 'changes', title: 'Changes to Privacy Policy' },
{ id: 'contact', title: 'Contact Information' },
];
// Helper function to parse and format heartbeat times in UTC
function parseAndFormatTime(rawTime) {
const dt = DateTime.fromFormat(rawTime, 'yyyy-MM-dd HH:mm:ss.SSS', { zone: 'utc' });
return dt.isValid ? dt.toFormat('dd-LL-yyyy, HH:mm:ss \"UTC\"') : 'Invalid DateTime UTC';
}
// Example usage: format all heartbeats in all lists
// (Assume apiData is your fetched API data)
// const apiData = { heartbeatList: { ... } };
// const formattedHeartbeatList = Object.fromEntries(
// Object.entries(apiData.heartbeatList).map(([key, arr]) => [
// key,
// arr.map(hb => ({ ...hb, formattedTime: parseAndFormatTime(hb.time) }))
// ])
// );
//
// Now, for each heartbeat, use hb.formattedTime for display in UTC.
---
<Layout metadata={metadata}>