Fixed handling of event dates (for #2)

This commit is contained in:
2025-05-02 12:20:24 +02:00
parent 80eae3f1b1
commit 5507295b1b
2 changed files with 29 additions and 11 deletions

View File

@@ -106,7 +106,7 @@ class CogEvent(Cog):
)
return
if not await validate_event_validity(ctx, name, start_date, end_date, guild_timezone):
if not await validate_event_validity(ctx, name, start_date, end_date, to_utc=True):
return
processed_media: List[Dict[str, Any]] = (
@@ -204,7 +204,12 @@ class CogEvent(Cog):
start_date: datetime = (
pycord_event.starts if start is None else datetime.strptime(start, "%d.%m.%Y %H:%M")
)
start_date = start_date.replace(tzinfo=guild_timezone)
start_date = (
start_date.replace(tzinfo=ZoneInfo("UTC"))
if start is None
else start_date.replace(tzinfo=guild_timezone)
)
except ValueError:
# TODO Make a nice message
await ctx.respond(
@@ -216,7 +221,12 @@ class CogEvent(Cog):
end_date: datetime = (
pycord_event.ends if end is None else datetime.strptime(end, "%d.%m.%Y %H:%M")
)
end_date = end_date.replace(tzinfo=guild_timezone)
end_date = (
end_date.replace(tzinfo=ZoneInfo("UTC"))
if end is None
else end_date.replace(tzinfo=guild_timezone)
)
except ValueError:
# TODO Make a nice message
await ctx.respond(
@@ -224,7 +234,7 @@ class CogEvent(Cog):
)
return
if not await validate_event_validity(ctx, name, start_date, end_date, guild_timezone):
if not await validate_event_validity(ctx, name, start_date, end_date, to_utc=True):
return
processed_media: List[Dict[str, Any]] = (