Кабинет: операции — даты периода по-русски, свежие сверху

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4YVo4UMopqT5DzicqpPjL
This commit is contained in:
zuevav
2026-09-18 15:58:20 +03:00
parent 68e1153cb2
commit c32df3752e
2 changed files with 12 additions and 1 deletions
+11
View File
@@ -79,6 +79,12 @@ func New(cfg Config) (*Server, error) {
}
return strings.ReplaceAll(s, ".", ",") + " %"
},
"fmtdate": func(iso string) string { // 2026-09-18 → 18.09.2026
if t, err := time.Parse("2006-01-02", iso); err == nil {
return t.Format("02.01.2006")
}
return iso
},
"fmtpct1": func(f float64) string { // 84,1%
return strings.ReplaceAll(strconv.FormatFloat(f, 'f', 1, 64), ".", ",") + "%"
},
@@ -765,6 +771,11 @@ func (s *Server) buildHandler() http.Handler {
s.render(w, r, "operations", data)
return
}
sort.SliceStable(out.Rows, func(i, j int) bool { // свежие сверху, независимо от порядка в ответе
di, _ := time.Parse("02.01.2006", out.Rows[i].Date)
dj, _ := time.Parse("02.01.2006", out.Rows[j].Date)
return di.After(dj)
})
var buy, sell, income float64
for _, o := range out.Rows {
switch o.Kind {
+1 -1
View File
@@ -490,7 +490,7 @@ input[type=checkbox]{width:20px;min-height:20px;height:20px}
<div>
<span class="lbl" style="color:var(--dim)">Операции</span>
<div class="big" style="margin-top:8px">{{len .Rows}}</div>
<div class="n" style="font-size:13px;color:var(--dim);margin-top:6px">за период {{.From}} — {{.To}}</div>
<div class="n" style="font-size:13px;color:var(--dim);margin-top:6px">за период {{fmtdate .From}} — {{fmtdate .To}}</div>
</div>
<div class="stats">
<span class="stat"><span class="lbl" style="color:var(--dim)">Покупки</span><span class="v">{{fmtmoney .BuyRUB}} ₽</span></span>