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
This commit is contained in:
shokollm
2026-04-04 23:54:34 +00:00
parent a76aab657f
commit 858305ebac

View File

@@ -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)"
)