refactor datestring function

This commit is contained in:
kenobi 2023-07-05 23:21:44 +02:00
parent ffba737e5a
commit 0748097a1f

View File

@ -4,14 +4,14 @@ import { GuildScheduledEvent } from "discord.js";
import { logger } from "../logger"; import { logger } from "../logger";
import de from "date-fns/locale/de"; import de from "date-fns/locale/de";
export function createDateStringFromEvent(event: GuildScheduledEvent, requestId: string, guildId?: string): string { export function createDateStringFromEvent(eventStartDate:Date, requestId: string, guildId?: string): string {
if (!event.scheduledStartAt) { if (!eventStartDate) {
logger.error("Event has no start. Cannot create dateString.", { guildId, requestId }) logger.error("Event has no start. Cannot create dateString.", { guildId, requestId })
return `"habe keinen Startzeitpunkt ermitteln können"` return `"habe keinen Startzeitpunkt ermitteln können"`
} }
const timeZone = 'Europe/Berlin' const timeZone = 'Europe/Berlin'
const zonedDateTime = utcToZonedTime(event.scheduledStartAt, timeZone) const zonedDateTime = utcToZonedTime(eventStartDate, timeZone)
const time = format(zonedDateTime, "HH:mm", { locale: de }) const time = format(zonedDateTime, "HH:mm", { locale: de })
if (isToday(zonedDateTime)) { if (isToday(zonedDateTime)) {