Skip to content

Commit 3f0901a

Browse files
author
Piotr Gulbinowicz
committed
change date displaying in flush listing
1 parent 78729e6 commit 3f0901a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

pwa/flush/components.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ func FLushTable(flushes []Flush) app.UI {
473473
}
474474
divs = append(divs,
475475
app.Div().Body(
476-
app.P().Text("Time: "+flush.TimeStart.Format(
477-
"2006-01-02 15:04")+" - "+flush.TimeEnd.Format("2006-01-02 15:04")),
476+
timeDiv(flush),
478477
app.P().Text("Rating: "+strconv.Itoa(flush.Rating)),
479478
app.P().Text("Phone used: "+phoneUsed),
480479
app.P().Text("Note: '"+flush.Note+"'"),
@@ -492,3 +491,25 @@ func FLushTable(flushes []Flush) app.UI {
492491
divs = append([]app.UI{statsDiv}, divs...)
493492
return app.Div().Body(divs...)
494493
}
494+
495+
func timeDiv(flush Flush) app.UI {
496+
flushDuration := strconv.FormatFloat(
497+
flush.TimeEnd.Sub(flush.TimeStart).Minutes(),
498+
'f',
499+
0,
500+
64,
501+
)
502+
if flush.TimeStart.Day() == flush.TimeEnd.Day() {
503+
return app.Div().Body(
504+
app.P().Text("Time: ").Class("font-bold inline"),
505+
app.P().Text(flushDuration+" minutes, "+flush.TimeStart.Format(
506+
"2006-01-02 15:04")+"-"+flush.TimeEnd.Format("15:04")).Class("inline"),
507+
)
508+
} else {
509+
return app.Div().Body(
510+
app.P().Text("Time: ").Class("font-bold inline"),
511+
app.P().Text(flushDuration+" minutes, "+flush.TimeStart.Format(
512+
"2006-01-02 15:04")+" - "+flush.TimeEnd.Format("2006-01-02 15:04")).Class("inline"),
513+
)
514+
}
515+
}

0 commit comments

Comments
 (0)