Improved event time loading #410
This commit is contained in:
parent
af3084ad36
commit
8a76b46165
@ -74,7 +74,8 @@ class EventService:
|
|||||||
active_event.participants.append(user)
|
active_event.participants.append(user)
|
||||||
|
|
||||||
def _append_interval(self, interval: ScheduledEventIntervalEnum, ts: datetime) -> datetime:
|
def _append_interval(self, interval: ScheduledEventIntervalEnum, ts: datetime) -> datetime:
|
||||||
if ts >= datetime.now():
|
now = datetime.now().replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||||
|
if ts >= now:
|
||||||
return ts
|
return ts
|
||||||
|
|
||||||
if interval == ScheduledEventIntervalEnum.daily:
|
if interval == ScheduledEventIntervalEnum.daily:
|
||||||
@ -90,7 +91,7 @@ class EventService:
|
|||||||
elif interval == ScheduledEventIntervalEnum.yearly:
|
elif interval == ScheduledEventIntervalEnum.yearly:
|
||||||
ts = ts + timedelta(days=365)
|
ts = ts + timedelta(days=365)
|
||||||
|
|
||||||
while ts < datetime.now():
|
while ts < now:
|
||||||
ts = self._append_interval(interval, ts)
|
ts = self._append_interval(interval, ts)
|
||||||
|
|
||||||
return ts
|
return ts
|
||||||
@ -114,12 +115,18 @@ class EventService:
|
|||||||
kwargs["channel"] = guild.get_channel(scheduled_event.channel_id)
|
kwargs["channel"] = guild.get_channel(scheduled_event.channel_id)
|
||||||
|
|
||||||
if scheduled_event.start_time is not None:
|
if scheduled_event.start_time is not None:
|
||||||
scheduled_event.start_time = self._append_interval(scheduled_event.interval, scheduled_event.start_time)
|
start_time = self._append_interval(
|
||||||
kwargs["start_time"] = scheduled_event.start_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
scheduled_event.interval, scheduled_event.start_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||||
|
)
|
||||||
|
kwargs["start_time"] = start_time
|
||||||
|
scheduled_event.start_time = scheduled_event.start_time.replace(tzinfo=None)
|
||||||
|
|
||||||
if scheduled_event.end_time is not None:
|
if scheduled_event.end_time is not None:
|
||||||
scheduled_event.end_time = self._append_interval(scheduled_event.interval, scheduled_event.end_time)
|
end_time = self._append_interval(
|
||||||
kwargs["end_time"] = scheduled_event.end_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
scheduled_event.interval, scheduled_event.end_time.replace(tzinfo=ZoneInfo("Europe/Berlin"))
|
||||||
|
)
|
||||||
|
kwargs["end_time"] = end_time
|
||||||
|
scheduled_event.end_time = scheduled_event.end_time.replace(tzinfo=None)
|
||||||
|
|
||||||
kwargs["entity_type"] = scheduled_event.entity_type
|
kwargs["entity_type"] = scheduled_event.entity_type
|
||||||
if scheduled_event.location is not None:
|
if scheduled_event.location is not None:
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
bot sh-edraft.de Discord bot
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Discord bot for customers of sh-edraft.de
|
|
||||||
|
|
||||||
:copyright: (c) 2022 - 2023 sh-edraft.de
|
|
||||||
:license: MIT, see LICENSE for more details.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
__title__ = "modules.base.thread"
|
|
||||||
__author__ = "Sven Heidemann"
|
|
||||||
__license__ = "MIT"
|
|
||||||
__copyright__ = "Copyright (c) 2022 - 2023 sh-edraft.de"
|
|
||||||
__version__ = "1.2.2"
|
|
||||||
|
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
|
|
||||||
# imports
|
|
||||||
|
|
||||||
VersionInfo = namedtuple("VersionInfo", "major minor micro")
|
|
||||||
version_info = VersionInfo(major="1", minor="2", micro="2")
|
|
Loading…
Reference in New Issue
Block a user