ops: dates shown as DD.MM.YYYY (bot, digest, reminders, BroV)
Storage and the API stay ISO; ru_day() formats every user-facing date, Claude is asked to write dates in its replies the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -322,12 +322,18 @@ struct OpsRow: View {
|
||||
}
|
||||
|
||||
private var subtitle: String {
|
||||
var parts = [item.date]
|
||||
var parts = [Self.ruDay(item.date)]
|
||||
if let a = item.amount { parts.append("\(a.formatted()) \(item.currency ?? "")") }
|
||||
if !item.client.isEmpty { parts.append(item.client) }
|
||||
return parts.joined(separator: " · ")
|
||||
}
|
||||
|
||||
/// 2026-11-15 → 15.11.2026
|
||||
static func ruDay(_ iso: String) -> String {
|
||||
let p = iso.prefix(10).split(separator: "-")
|
||||
return p.count == 3 ? "\(p[2]).\(p[1]).\(p[0])" : iso
|
||||
}
|
||||
|
||||
private func small(_ symbol: String, _ help: String, _ action: @escaping () -> Void) -> some View {
|
||||
Button(action: action) {
|
||||
Image(systemName: symbol).font(.system(size: 13)).foregroundColor(Color(hex: "#B0B5BE"))
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ from telegram.ext import (Application, CallbackQueryHandler, CommandHandler, Con
|
||||
filters)
|
||||
|
||||
from . import brain, fmt, voice
|
||||
from .core import Ops, OpsError
|
||||
from .core import Ops, OpsError, ru_day
|
||||
from .db import connect
|
||||
|
||||
log = logging.getLogger("brovops")
|
||||
@@ -186,10 +186,10 @@ async def on_button(update: Update, ctx):
|
||||
note = f"✓ Сделано: {ops.complete_task(ref)['title']}"
|
||||
elif kind == "sub":
|
||||
s = ops.pay_sub(ref)
|
||||
note = f"₽ Оплачено: {s['name']}, следующее списание {s['next_date']}"
|
||||
note = f"₽ Оплачено: {s['name']}, следующее списание {ru_day(s['next_date'])}"
|
||||
else:
|
||||
r = ops.done_routine(ref)
|
||||
note = f"✓ {r['title']}: следующий раз {r['next_date']}"
|
||||
note = f"✓ {r['title']}: следующий раз {ru_day(r['next_date'])}"
|
||||
else:
|
||||
ops.snooze(kind, ref, 1)
|
||||
note = "⏰ Напомню завтра"
|
||||
|
||||
@@ -6,7 +6,7 @@ import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
from .core import Ops, OpsError
|
||||
from .core import Ops, OpsError, ru_day
|
||||
|
||||
INSTRUCTIONS = """Ты — помощник-менеджер системного администратора. Пользователь пишет или говорит
|
||||
по-русски, коротко и неформально. Твоя задача — превратить сообщение в действия над его базой дел.
|
||||
@@ -31,7 +31,8 @@ INSTRUCTIONS = """Ты — помощник-менеджер системног
|
||||
- update_routine {id, title?, every_days?, next_date?, notes?, active?}
|
||||
|
||||
Правила:
|
||||
- Даты — строго ГГГГ-ММ-ДД. «завтра», «в пятницу», «15-го» переводи от сегодняшней даты.
|
||||
- В полях действий даты — строго ГГГГ-ММ-ДД. «завтра», «в пятницу», «15-го» переводи от сегодняшней даты.
|
||||
- В тексте reply даты пиши как ДД.ММ.ГГГГ (например 15.11.2026).
|
||||
- client — одно из: saga, planet9, home, или пусто.
|
||||
- Если пользователь просто спрашивает (что на сегодня, сколько трачу, что просрочено) —
|
||||
actions пустой, ответ в reply по данным ниже.
|
||||
@@ -109,7 +110,7 @@ def apply_plan(ops: Ops, plan: dict) -> list[str]:
|
||||
if a.get("key"):
|
||||
keys[a["key"]] = t["id"]
|
||||
done.append(f"+ задача #{t['id']} {t['title']}" + (f" (подзадача #{t['parent_id']})" if t["parent_id"] else "")
|
||||
+ (f", срок {t['due']}" if t["due"] else ""))
|
||||
+ (f", срок {ru_day(t['due'])}" if t["due"] else ""))
|
||||
elif op == "update_task":
|
||||
t = ops.update_task(int(a["id"]), **_only(args, "title", "due", "client", "notes", "status"))
|
||||
done.append(f"✎ задача #{t['id']} {t['title']}")
|
||||
@@ -128,20 +129,20 @@ def apply_plan(ops: Ops, plan: dict) -> list[str]:
|
||||
elif op == "add_sub":
|
||||
s = ops.add_sub(**_only(args, "name", "amount", "next_date", "period", "every", "currency",
|
||||
"remind_days", "notes"))
|
||||
done.append(f"+ подписка #{s['id']} {s['name']}: {s['amount']:g} {s['currency']}, след. {s['next_date']}")
|
||||
done.append(f"+ подписка #{s['id']} {s['name']}: {s['amount']:g} {s['currency']}, след. {ru_day(s['next_date'])}")
|
||||
elif op == "update_sub":
|
||||
s = ops.update_sub(int(a["id"]), **_only(args, "name", "amount", "next_date", "period", "every",
|
||||
"currency", "remind_days", "notes", "active"))
|
||||
done.append(f"✎ подписка #{s['id']} {s['name']}")
|
||||
elif op == "pay_sub":
|
||||
s = ops.pay_sub(int(a["id"]), a.get("amount"), a.get("paid_on"))
|
||||
done.append(f"₽ оплачено: {s['name']}, следующее списание {s['next_date']}")
|
||||
done.append(f"₽ оплачено: {s['name']}, следующее списание {ru_day(s['next_date'])}")
|
||||
elif op == "add_routine":
|
||||
r = ops.add_routine(**_only(args, "title", "every_days", "next_date", "notes"))
|
||||
done.append(f"+ регламент #{r['id']} {r['title']}: раз в {r['every_days']} дн., след. {r['next_date']}")
|
||||
done.append(f"+ регламент #{r['id']} {r['title']}: раз в {r['every_days']} дн., след. {ru_day(r['next_date'])}")
|
||||
elif op == "done_routine":
|
||||
r = ops.done_routine(int(a["id"]), a.get("note", ""))
|
||||
done.append(f"✓ {r['title']}: следующий раз {r['next_date']}")
|
||||
done.append(f"✓ {r['title']}: следующий раз {ru_day(r['next_date'])}")
|
||||
elif op == "update_routine":
|
||||
r = ops.update_routine(int(a["id"]), **_only(args, "title", "every_days", "next_date", "notes", "active"))
|
||||
done.append(f"✎ регламент #{r['id']} {r['title']}")
|
||||
|
||||
@@ -28,6 +28,16 @@ def add_period(d: date, period: str, every: int = 1) -> date:
|
||||
raise OpsError(f"неизвестный период: {period}")
|
||||
|
||||
|
||||
def ru_day(iso) -> str:
|
||||
"""2026-11-15 → 15.11.2026 (how dates are shown; storage stays ISO)."""
|
||||
if not iso:
|
||||
return ""
|
||||
try:
|
||||
return date.fromisoformat(str(iso)[:10]).strftime("%d.%m.%Y")
|
||||
except ValueError:
|
||||
return str(iso)
|
||||
|
||||
|
||||
def parse_day(s) -> date | None:
|
||||
if s in (None, ""):
|
||||
return None
|
||||
|
||||
+5
-3
@@ -2,6 +2,8 @@
|
||||
from datetime import date
|
||||
from html import escape
|
||||
|
||||
from .core import ru_day
|
||||
|
||||
ICON = {"task": "📌", "sub": "💳", "routine": "🔁"}
|
||||
|
||||
|
||||
@@ -16,7 +18,7 @@ def human_day(iso: str, today: date) -> str:
|
||||
return "вчера"
|
||||
if delta < 0:
|
||||
return f"просрочено на {-delta} дн."
|
||||
return d.strftime("%d.%m")
|
||||
return d.strftime("%d.%m.%Y")
|
||||
|
||||
|
||||
def item_line(it: dict, today: date) -> str:
|
||||
@@ -45,7 +47,7 @@ def tree(nodes: list, depth: int = 0) -> list[str]:
|
||||
out = []
|
||||
for t in nodes:
|
||||
mark = "⏱" if t["running"] else ("▶️" if t["status"] == "doing" else "▫️")
|
||||
due = f" · до {t['due']}" if t["due"] else ""
|
||||
due = f" · до {ru_day(t['due'])}" if t["due"] else ""
|
||||
mins = f" · {t['minutes']} мин" if t["minutes"] else ""
|
||||
client = f" [{t['client']}]" if t["client"] else ""
|
||||
out.append(f"{' ' * depth}{mark} #{t['id']} {escape(t['title'])}{client}{due}{mins}")
|
||||
@@ -67,4 +69,4 @@ def routines(rows: list, today: date) -> str:
|
||||
if not rows:
|
||||
return "Регламентных дел пока нет. Скажи: «бэкап NAS раз в неделю»."
|
||||
return "\n".join(f"🔁 #{r['id']} {escape(r['title'])} · раз в {r['every_days']} дн. · {human_day(r['next_date'], today)}"
|
||||
+ (f" · последний раз {r['last_done']}" if r["last_done"] else "") for r in rows)
|
||||
+ (f" · последний раз {ru_day(r['last_done'])}" if r["last_done"] else "") for r in rows)
|
||||
|
||||
Reference in New Issue
Block a user