From 858305ebac295e416875f38b8520e8d2586a18da Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Sat, 4 Apr 2026 23:54:34 +0000 Subject: [PATCH] fix: show time in date display and bounty list 1. format_bounty now shows time (HH:MM) if time is set 2. Bounty list shows hours remaining if < 48 hours: - < 1 hour: shows minutes (e.g., 45m) - < 48 hours: shows hours (e.g., 6h) - >= 48 hours: shows days (e.g., 3d) 3. Update message now shows time in date display --- apps/telegram-bot/commands.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/telegram-bot/commands.py b/apps/telegram-bot/commands.py index 43ac0a8..23e1dd5 100644 --- a/apps/telegram-bot/commands.py +++ b/apps/telegram-bot/commands.py @@ -156,12 +156,21 @@ def format_bounty(b, show_id: bool = True, slice_length: int = 0) -> str: if b.link: parts.append(f"🔗 {b.link}") if b.due_date_ts: - due_str = time.strftime("%d %b %Y", time.localtime(b.due_date_ts)) - days_left = (b.due_date_ts - int(time.time())) // 86400 - if days_left < 0: + now = int(time.time()) + seconds_left = b.due_date_ts - now + hours_left = seconds_left // 3600 + days_left = seconds_left // 86400 + + due_str = time.strftime("%d %b %Y %H:%M", time.localtime(b.due_date_ts)) + + if seconds_left < 0: parts.append(f"⏰ {due_str} (OVERDUE)") - elif days_left == 0: - parts.append(f"⏰ Today (OVERDUE)") + elif hours_left < 48: + if hours_left < 1: + minutes_left = seconds_left // 60 + parts.append(f"⏰ {due_str} ({minutes_left}m)") + else: + parts.append(f"⏰ {due_str} ({hours_left}h)") else: parts.append(f"⏰ {due_str} ({days_left}d)") return " | ".join(parts) @@ -416,18 +425,18 @@ async def cmd_update(update: Update, ctx: ContextTypes.DEFAULT_TYPE) -> None: changes.append(f"Link: {old_link} → {link}") if due_date_ts is not None: old_date = ( - time.strftime("%d %b %Y", time.localtime(old_bounty.due_date_ts)) + time.strftime("%d %b %Y %H:%M", time.localtime(old_bounty.due_date_ts)) if old_bounty.due_date_ts else "(none)" ) - new_date = time.strftime("%d %b %Y", time.localtime(due_date_ts)) + new_date = time.strftime("%d %b %Y %H:%M", time.localtime(due_date_ts)) changes.append(f"Date: {old_date} → {new_date}") if clear_link: old_link = old_bounty.link or "(none)" changes.append(f"Link: {old_link} → (cleared)") if clear_date: old_date = ( - time.strftime("%d %b %Y", time.localtime(old_bounty.due_date_ts)) + time.strftime("%d %b %Y %H:%M", time.localtime(old_bounty.due_date_ts)) if old_bounty.due_date_ts else "(none)" )