Rename all workspace packages to reflect the actual project name: - @caldav/client -> @calchat/client - @caldav/server -> @calchat/server - @caldav/shared -> @calchat/shared - Root package: caldav-mono -> calchat-mono Update all import statements across client and server to use the new package names. Update default MongoDB database name and logging service identifier accordingly.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { CalendarEvent } from "@calchat/shared";
|
|
|
|
// German date/time formatting helpers
|
|
export const formatDate = (d: Date) => d.toLocaleDateString("de-DE");
|
|
export const formatTime = (d: Date) =>
|
|
d.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit" });
|
|
export const formatDateTime = (d: Date) =>
|
|
`${formatDate(d)} ${d.toLocaleTimeString("de-DE")}`;
|
|
|
|
/**
|
|
* Format a list of events for display in the system prompt.
|
|
* Output is in German with date/time formatting.
|
|
*/
|
|
export function formatExistingEvents(events: CalendarEvent[]): string {
|
|
if (events.length === 0) {
|
|
return "Keine Termine vorhanden.";
|
|
}
|
|
|
|
return events
|
|
.map((e) => {
|
|
const start = new Date(e.startTime);
|
|
const end = new Date(e.endTime);
|
|
const timeStr = `${formatTime(start)} - ${formatTime(end)}`;
|
|
const recurring = e.isRecurring ? " (wiederkehrend)" : "";
|
|
const desc = e.description ? ` | ${e.description}` : "";
|
|
return `- ${e.title} (ID: ${e.id}) | ${formatDate(start)} ${timeStr}${recurring}${desc}`;
|
|
})
|
|
.join("\n");
|
|
}
|