new timestamp feature and make tz data shared across cogs that need it

This commit is contained in:
esef committed 2026-07-20 21:18:43 +03:00
1 parent 7d754367ae
commit 7018366068
7 files changed
+428 -23

No files matched your search

+2 -19
View File
@@ -10,7 +10,7 @@ import discord
from discord.ext import commands
from firebase_website import get_db
from .calendar_data import COUNTRY_TZ
from .tz_data import COUNTRY_TZ, find_offset
log = logging.getLogger(__name__)
@@ -22,23 +22,6 @@ TR_TZ = timezone(timedelta(hours=3))
WH_NAME = "koharu"
def _find_offset(country: str) -> float | None:
"""Look up a country's UTC offset. Case-insensitive fuzzy match."""
c = country.strip().lower()
if not c:
return None
for name, offset in COUNTRY_TZ.items():
if c == name.lower():
return offset
for name, offset in COUNTRY_TZ.items():
if name.lower().startswith(c):
return offset
for name, offset in COUNTRY_TZ.items():
if c in name.lower():
return offset
return None
# ==========================================
# BOOK MODAL
# ==========================================
@@ -130,7 +113,7 @@ class BookModal(discord.ui.Modal, title="Book an Event"):
)
# --- timezone lookup ---
offset = _find_offset(country)
offset = find_offset(country)
if offset is None:
return await interaction.response.send_message(
"Unknown country. Try: Turkey, UK, US East, Japan, etc.",