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:
@@ -156,12 +156,21 @@ def format_bounty(b, show_id: bool = True, slice_length: int = 0) -> str:
|
|||||||
if b.link:
|
if b.link:
|
||||||
parts.append(f"🔗 {b.link}")
|
parts.append(f"🔗 {b.link}")
|
||||||
if b.due_date_ts:
|
if b.due_date_ts:
|
||||||
due_str = time.strftime("%d %b %Y", time.localtime(b.due_date_ts))
|
now = int(time.time())
|
||||||
days_left = (b.due_date_ts - int(time.time())) // 86400
|
seconds_left = b.due_date_ts - now
|
||||||
if days_left < 0:
|
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)")
|
parts.append(f"⏰ {due_str} (OVERDUE)")
|
||||||
elif days_left == 0:
|
elif hours_left < 48:
|
||||||
parts.append(f"⏰ Today (OVERDUE)")
|
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:
|
else:
|
||||||
parts.append(f"⏰ {due_str} ({days_left}d)")
|
parts.append(f"⏰ {due_str} ({days_left}d)")
|
||||||
return " | ".join(parts)
|
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}")
|
changes.append(f"Link: {old_link} → {link}")
|
||||||
if due_date_ts is not None:
|
if due_date_ts is not None:
|
||||||
old_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
|
if old_bounty.due_date_ts
|
||||||
else "(none)"
|
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}")
|
changes.append(f"Date: {old_date} → {new_date}")
|
||||||
if clear_link:
|
if clear_link:
|
||||||
old_link = old_bounty.link or "(none)"
|
old_link = old_bounty.link or "(none)"
|
||||||
changes.append(f"Link: {old_link} → (cleared)")
|
changes.append(f"Link: {old_link} → (cleared)")
|
||||||
if clear_date:
|
if clear_date:
|
||||||
old_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
|
if old_bounty.due_date_ts
|
||||||
else "(none)"
|
else "(none)"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user